1

I know it is impossible to close a running 3rd party app. But what if i opened the 3rd party app within my app? Is there a way to close/finish it?

AkBaylife
  • 11
  • 2

1 Answers1

2

Yes it is possible but the user should have that app installed on his device. see following links

Open another application from your own (intent)

Launch an application from another application on Android

ActivityManager am = (ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE);
    List<ActivityManager.RunningAppProcessInfo> pids = am.getRunningAppProcesses();
             int processid = 0;
       for(int i = 0; i < pids.size(); i++)
       {
           ActivityManager.RunningAppProcessInfo info = pids.get(i);
           if(info.processName.equalsIgnoreCase("here your package name")){
              processid = info.pid;
           } 
       }
android.os.Process.killProcess(processid);

Hope it will help :)

Community
  • 1
  • 1
Nitin
  • 1,948
  • 3
  • 22
  • 53
  • I know how to open an installed app with an intent. All i want is just to close it again. – AkBaylife Dec 09 '14 at 05:30
  • you can not do it as it is not available within same Context. – Nitin Dec 09 '14 at 05:33
  • if you run some thing in service you can try android.os.Process.killProcess(android.os.Process.processid); but for that you need to have processid – Nitin Dec 09 '14 at 05:37