Android.os.Process.killProcess not working
Hi I am making an android app that closes google music app based on a timer. I am using the following code to disable the background music
:
ActivityManager a = (ActivityManager)this.getSystemService(ACTIVITY_SERVICE);
int pid = android.os.Process.getUidForName("com.google.android.music");
a.killBackgroundProcesses("com.google.android.music");
android.os.Process.killProcess(pid);
Even after using both methods killProcess
and killBackgroundProcesses
it doesn't work on my device. Everyone knows why this is so?
Thanks in advance.
source to share
In your AndroidManifest.xml:
android:name="android.permission.GET_TASKS"
android:name="android.permission.KILL_BACKGROUND_PROCESSES"
and
android:excludeFromRecents="true"
Whether to exclude the task initiated by this action from the list of recently used applications ("recent applications"). That is, when this action is the root activity of a new task, this attribute determines whether the task should not appear in the Recent Programs list. "true" if the task should be excluded from the list; "false" if it should be enabled. The default is "false".
http://developer.android.com/guide/topics/manifest/activity-element.html#exclude
source to share