Can I end or kill other process running, programmatically? I'm asked my friend and tell me should using something like kiosk mode !!
Could anyone help me to solve this problem ..
All regards and thanks.
Can I end or kill other process running, programmatically? I'm asked my friend and tell me should using something like kiosk mode !!
Could anyone help me to solve this problem ..
All regards and thanks.
try this code
kill all process but not system process
// TODO clean servise
Just to make it clear and this is how it worked for me for rooted phone (which means su command is available to the device):
where pid is the process id of the app you want to kill, which should be an number.
Please note this is also system dependent. In some system without "sh -c ", it would work. In some system, you need specify uid after su command:
Hope it helps.
David
I think you can try something like
android.os.Process.killProcess(android.os.Process.myPid());
but if you want kill other processes youd must have root permission (in general, you haven't it)
Since Android 2.2 (or higher, I don't remember), you can only kill your own app using an intent. To kill another processes from your app you must have rooted device, parse the
ps
command output manually, get needed process ids, exec thesu
, write thekill
command to this pipe, and here we go. I wrote this code for my own library, so this methods are separated, but hope you'll understand:Recently I was investigating the same question, because I got tired of manually having to close the Google Maps application that regularly automatically opens and keeps running in the background and draining my battery...
But I don't think that Android lets you kill any processes but your own. This is good for security purposes, but I would at least liked them to include an application permission so programs are able to do it if allowed by the user.
I tried the following approaches and not one of them is working:
It was pointed out by a user that it is not possible since Android 2.1. See here: https://stackoverflow.com/a/6535201/4090002
Since the Android OS has other limitations for us users as well, users are forced to live with silly limitations and reduced rights to do anything about them. I don't know about the other mobile OS, but this is where Android s***s big time.