Android Question Zip in service blocks activity

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

  1. Nickelgrass

    Nickelgrass Active Member Licensed User

    Hi,
    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

    Code:
    #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/zipfile.zip")
        
    StopService("")
    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
    Code:
    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)
        
    Activity.LoadLayout("main")
        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""zipfile.zip") & "  " & cn
        cn = cn + 
    1
    End Sub
    Whats going on here???

    Thanks!
     
  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.
Loading...
  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