Android Question Killing a service from a watchdog app.

JakeBullet70

Well-Known Member
Licensed User
Longtime User
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" />)

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?
 

JakeBullet70

Well-Known Member
Licensed User
Longtime User
The OS lib seems to work OK.
I am seeing a 'Sending signal. PID: 14770 SIG: 9' in the unfiltered logs which is the kill signal. It's just not dying a dignified death .
 
Upvote 0

JakeBullet70

Well-Known Member
Licensed User
Longtime User
Just found you Inter-app Communication with Intents. I will give that a shot in the morning. Thanks again.
 
Upvote 0

JakeBullet70

Well-Known Member
Licensed User
Longtime User
I have used memory mapped files in Windows for real time communications. Might as well start understanding intents... :) I wonder if Java supports memory mapped files...
 
Upvote 0
Top