Android Question Add a Pause in Sub Activity_Pause ?

  • Thread starter Thread starter Deleted member 103
  • Start date Start date
  • Similar Threads Similar Threads Similar Threads
D

Deleted member 103

Guest
Hi,
can one add a pause in sub "Activity_Pause" so that certain operations are executed before the function "ExitApplication"?

I ask because I want to be sure that certain services have been terminated.

Is this possible? Here's an example.
Or is there another possibility to wait until the service were to quit?

Code: Copy
Sub Activity_Pause (UserClosed As Boolean)

    If UserClosed Then
       
        'Service beenden
        CallSub(smCrono, "Service_Stop")
        CallSub(smAtomtime, "Service_Stop")
        CallSub(Starter, "Service_Stop")

        Sleep(200) 'I do not know whether this time is sufficient.

        ExitApplication
    End If
   
End Sub
 
OK, if you use "ExitApplication" then it is no longer necessary to stop the service manually, with "ExitApplication" the services are automatically terminated. :p
 
Upvote 0
Have you tried using a timer to start ExitApplication after a time?
 
Upvote 0
I think you can use a sub like this
In activity pause:
Code: Copy
CallSub2(YourService,"SubFinish",Me)
Wait for Finish_Service
CallSub2(YourService2,"SubFinish2",Me)
Wait for Finish_Service2

In service
Code: Copy
Sub Process_Globals
    CallBack as object
End Sub

Sub SubFinish(cb as object)
callback = cb
StopService(me)
End Sub

Sub Service_Destroy
CallSubDelayed(CallBack,"Finish_Service")
End Sub
 
Upvote 0
It will not work as the resumable sub will not be resumed until the activity is resumed.
That's right, I have already tried.

I tried it that way, and it seems to work.

In activity pause:
Code: Copy
Sub Activity_Pause (UserClosed As Boolean)

    If UserClosed Then
      
        'Service beenden
        CallSub(smCrono, "Service_Stop")
        CallSub(smAtomtime, "Service_Stop")
        CallSub(Starter, "Service_Stop")

        ExitApplication
    End If
  
End Sub

In service:
Code: Copy
Public Sub Service_Stop
    StopService(Me)
End Sub

Logs without Stop-Service:
[GICON] ### GPS_ENABLED_CHANGE_ACTION ### (false)
reportStatus status: 4
sendEvent(1,0,700120834,false) back
Recipient 21267
Buffer count: 4
WIN DEATH: Window{e941df9 u0 fg.cronomillemiglia_ultra/fg.cronomillemiglia_ultra.main}
Process fg.cronomillemiglia_ultra (pid 21267) has died
cleanUpApplicationRecord -- 21267
Scheduling restart of crashed service fg.cronomillemiglia_ultra/.smcrono in 1000ms
Scheduling restart of crashed service fg.cronomillemiglia_ultra/.starter in 1000ms
failed to post message as target looper for handler 0 is gone.
failed to post message as target looper for handler 0 is gone.
failed to post message as target looper for handler 0 is gone.
failed to post message as target looper for handler 0 is gone.
failed to post message as target looper for handler 0 is gone.
failed to post message as target looper for handler 0 is gone.
failed to post message as target looper for handler 0 is gone.
failed to post message as target looper for handler 0 is gone.
failed to post message as target looper for handler 0 is gone.
Looper::removeFd(52) is failed, result(0), input channel 'ClientState{a40316d uid 10210 pid 21267} (client)'
failed to post message as target looper for handler 0 is gone.
failed to post message as target looper for handler 0 is gone.
HtcSystemUPolicy [canLog (default)] category: launch, enable: true

Logs with Stop-Service:
[GICON] ### GPS_ENABLED_CHANGE_ACTION ### (false)
reportStatus status: 4
sendEvent(1,0,700324198,false) back
Recipient 22082
failed to post message as target looper for handler 0 is gone.
Buffer count: 4
WIN DEATH: Window{8780823 u0 fg.cronomillemiglia_ultra/fg.cronomillemiglia_ultra.main}
failed to post message as target looper for handler 0 is gone.
failed to post message as target looper for handler 0 is gone.
Process fg.cronomillemiglia_ultra (pid 22082) has died
cleanUpApplicationRecord -- 22082
failed to post message as target looper for handler 0 is gone.
failed to post message as target looper for handler 0 is gone.
Looper::removeFd(52) is failed, result(0), input channel 'ClientState{5489e8b uid 10210 pid 22082} (client)'
failed to post message as target looper for handler 0 is gone.
failed to post message as target looper for handler 0 is gone.
failed to post message as target looper for handler 0 is gone.
failed to post message as target looper for handler 0 is gone.
failed to post message as target looper for handler 0 is gone.
failed to post message as target looper for handler 0 is gone.
 
Upvote 0
In activity pause:
Code: Copy
Sub Activity_Pause (UserClosed As Boolean)

    If UserClosed Then
     
        'Service beenden
        CallSub(smCrono, "Service_Stop")
        CallSub(smAtomtime, "Service_Stop")
        CallSub(Starter, "Service_Stop")

        ExitApplication
    End If
 
End Sub

Logs with Stop-Service:
You can use also stopService(name), don't need callsub
 
Upvote 0
Back
Top