Automate closing of applications in Android

前端 未结 1 761
后悔当初
后悔当初 2020-12-08 03:32

I\'ve read a lot of documentation and other posts about closing other apps. I know the documentation says Android isn\'t designed that way. Android wants to hibernate an app

1条回答
  •  遥遥无期
    2020-12-08 04:18

    What you said is perfectly possible. Just get the ActivityManager system service and then use .restartPackage() (deprecated) or .killBackgroundProcesses().

    ActivityManager activityManager = (ActivityManager) context.getSystemService("activity");
    activityManager.restartPackage(packageName);
    

    You will need:

    
    
    

    0 讨论(0)
提交回复
热议问题