0

I want to develop such type of application that closed the current running application.

I tried below code:

       ActivityManager actvityManager = (ActivityManager)this.getSystemService( ACTIVITY_SERVICE );
                List<RunningAppProcessInfo> procInfos = actvityManager.getRunningAppProcesses();

                for(RunningAppProcessInfo runningProInfo:procInfos){


                        if(runningProInfo.processName.equals("com.teamviewer.quicksupport.market")){
                            System.out.println("Running Processes"+ "()()"+runningProInfo.processName);

                              android.os.Process.killProcess(runningProInfo.pid);
                             // ActivityManager activityManager = (ActivityManager) getSystemService(ACTIVITY_SERVICE);
                             // actvityManager.killBackgroundProcesses(runningProInfo.processName);
                        }
       }

But not working.

Is there any way to closed other application from my android application, Without root permission.

Please help me.

Hemantvc
  • 2,111
  • 3
  • 30
  • 42

1 Answers1

0

Try ActivityManager.killBackgroundProcesses(). However, it will only kill backgrounded processes, not the foreground one. That would be a security problem if any app could kill any other app, especially one the user is currently utilizing.

Larry Schiefer
  • 15,687
  • 2
  • 27
  • 33