Android Question App Not Exiting From Button - Can't Work Out Why

woodpecker

Member
Licensed User
Longtime User
My app uses one activity (Main), Starter service and a service called scan. I am trying to shut down the whole app by clicking an Exit button in the menu but its not working and I can't see why.

I have a boolean called killapp.

The button calls this sub:-

B4X:
Sub mnuExit_Click
    killapp = True
    StopService(scan)
    StopService(Starter)
    Activity.Finish
End Sub

In Activity_Pause and Activity_Resume I have this:-

B4X:
If killapp = True Then
        admin.Disable
        pw.ReleaseKeepAlive
        Log("Kill App is " & killapp)
        StopService(scan)
        StopService(Starter)
        Activity.Finish
    End If

The app appears to close but is still open (or at least partially open), in the log I see as below, how can I debug what is not closing properly?

HWUI GL Pipeline
** Service (scan) Destroy **
Stopping scan
** Service (starter) Destroy (ignored)**
** Activity (main) Pause, UserClosed = true **
Kill App is true
ignoring event: admin_statechanged
ignoring event: admin_statechanged
onBluetoothServiceDown: android.bluetooth.IBluetooth$Stub$Proxy@58652a1
onBluetoothServiceDown: Sending callbacks to 0 clients
onBluetoothServiceDown: Finished sending callbacks to registered clients
ignoring event: gps_gpsstatus
ignoring event: gps_gpsstatus
ignoring event: gps_locationchanged
ignoring event: gps_gpsstatus
onBluetoothServiceUp: android.bluetooth.IBluetooth$Stub$Proxy@18ad487
onBluetoothServiceDown: android.bluetooth.IBluetooth$Stub$Proxy@18ad487
onBluetoothServiceDown: Sending callbacks to 0 clients
onBluetoothServiceDown: Finished sending callbacks to registered clients
onBluetoothServiceUp: android.bluetooth.IBluetooth$Stub$Proxy@c47cfb4
 

Semen Matusovskiy

Well-Known Member
Licensed User
It's impossible to say something without a code.
For example, I see StopService (Starter). In B4A 8.3 Destroy event happens, but service continue to work. Probably, you app doesn't expect this.

Or ExitApplication. It not always kills the application. B4A uses System.exit (0), which restarts the app with one fewer activity on the stack.
So, if you called activity Two from activity Main, and System.exit (0) is called in activity Two, then the application will be killed and started immediately with only one activity (Main). See attached sample
 

Attachments

  • testExitAppication.zip
    8.2 KB · Views: 112
Upvote 0
Top