Android Question Zip in service blocks activity

Discussion in 'Android Questions' started by Nickelgrass, May 25, 2015.

  1. Nickelgrass

    Nickelgrass 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
    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.Enabled = 
    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 + 
    End Sub
    Whats going on here???

  2. Troberg

    Troberg 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'.
  3. Nickelgrass

    Nickelgrass Active Member Licensed User

    Ok, thanks for the hint! I found that the Archiver library runs in its own thread and it works like a charm :)
    Troberg likes this.
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice