kill process - Getting an Android app to start and stop a third party app -


i have android app uses activity start app (a third party app). after events have taken place, want activity stop/hide/kill third party app.

starting third party app easy, cannot find way stop it.

i have read on net how should done , cannot seem outcome want. @ point seems impossible without rooted device.

if can suggest better way of doing this, appreciated.

i if uid of third party app different, calls kernel kill third party app ignored, given have started app, think there must way stop it.

i have included of code have used/tried - comments. third party app called com.xxx.

            //start activity         string packagename = "com.xxx";         intent startintent = this.getpackagemanager().getlaunchintentforpackage(packagename);             startactivity(startintent);          //attempts stop app         list<activitymanager.runningappprocessinfo> activityes = ((activitymanager)am).getrunningappprocesses();         (int icnt = 0; icnt < activityes.size(); icnt++) {             if (activityes.get(icnt).processname.contains(packagename)) {                 (int = 0; < 10; i++) {                     try {                          //method - call processed had no effect                          android.os.process.killprocess(activityes.get(icnt).pid);                         am.killbackgroundprocesses(packagename);                          // method b- same result above                         android.os.process.sendsignal(activityes.get(icnt).pid, android.os.process.signal_kill);                         am.restartpackage(packagename);                          //method c - no effect                         string[] command = {"kill", "-9", ""+activityes.get(icnt).pid};                         processbuilder processbuilder = new processbuilder(command);                         process process = processbuilder.start();                         process.waitfor();                          //method d - generates exception no su rights                         process process2 = runtime.getruntime().exec(new string[] { "su", "-c", "kill -9 " + packagename + "\n"});                         process process2 = runtime.getruntime().exec(new string[] { "adb", "root", "kill -9 " + packagename + "\n"});                          //method e - generates exception no su rights                         process suprocess1 = runtime.getruntime().exec("adb shell echo \"kill -9 \" + packagename + "\" | su");                         suprocess1.waitfor();                         process suprocess2 = runtime.getruntime().exec("/system/bin/su -c kill -9 " + packagename);                         suprocess2.waitfor();                           //method f - generates exception no su rights                         process suprocess3 = runtime.getruntime().exec("su");                         dataoutputstream os = new dataoutputstream(suprocess3.getoutputstream());                         os.writebytes("adb shell" + "\n");                         os.writebytes("am force-stop " + packagename + "\n");                         os.writebytes("kill -9 " + packagename + "\n");                         os.flush();                         os.close();                       } catch (exception e) {                         log.d("debug", + "b/" + e.getlocalizedmessage());                     }                 }             }         } 


Comments

Popular posts from this blog

facebook - android ACTION_SEND to share with specific application only -

python - Creating a new virtualenv gives a permissions error -

javascript - cocos2d-js draw circle not instantly -