Android Question Zip in service blocks activity


Active Member
Licensed User
its a simple thing that I cant get to work :(

I have an activity and a service. The service simply zips a folder to a nother folder

#Region  Service Attributes
    #StartAtBoot: False
#End Region

Sub Process_Globals
End Sub

Sub Service_Create
End Sub

Sub Service_Start (StartingIntent As Intent)
    Dim zip As ABZipUnzip
    zip.ABZipDirectory("somefolder", "someotherfolder/")
End Sub

Sub Service_Destroy
End Sub

The problem is that also my activity hangs. I get prompted all the time that it is not responding and if it should get closed. How can the service affect my activity. I need to zip large folders so it takes some time.

This is all my activity does
Sub Process_Globals
    Dim tim As Timer
    Dim cn As Int
End Sub

Sub Globals
    Private Label1 As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
    tim.Initialize("tim", 1000)
    tim.Enabled = True
    If IsPaused(zipservice) Then StartService(zipservice)
End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub tim_Tick
    Label1.Text = File.Size("someotherfolder", "") & "  " & cn
    cn = cn + 1
End Sub

Whats going on here???



Well-Known Member
Licensed User
I suspect that the problem is that the service, while having a different Life cycle, does not run in it's own thread. In this case, I think you'll have to dive into the threading library to avoid 'Application not responding'.
Upvote 0