Hi all.
I have a watchdog app that watches my kiosk app and if it crashes it will be restarted. But when it crashes it does not always stop all services. So... How can the watchdog app kill the main apps services?
I am using the OSLib.
I have tried this code. (and added this to the manifest:
(<user-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
<user-permission android:name="android.permission.GET_TASKS" />)
Am I missing something? Is there a better way?
I have a watchdog app that watches my kiosk app and if it crashes it will be restarted. But when it crashes it does not always stop all services. So... How can the watchdog app kill the main apps services?
I am using the OSLib.
I have tried this code. (and added this to the manifest:
(<user-permission android:name="android.permission.KILL_BACKGROUND_PROCESSES" />
<user-permission android:name="android.permission.GET_TASKS" />)
B4X:
Dim os As OperatingSystem
os.Initialize("")
Dim l As List : l.Initialize
l = os.getRunningServices(500)
For x = 0 To l.Size - 1
Dim obj As JavaObject = l.Get(x)
Dim name As String = obj.GetField("process")
If name.ToUpperCase.Trim.EndsWith("CENTRAL") Then
Dim pid As Object = obj.GetField("pid")
os.killProcess(pid)
End If
Next
Am I missing something? Is there a better way?