How to force stop my android application programmatically?

前端 未结 6 985
天涯浪人
天涯浪人 2020-11-27 05:59

I\'d like to force stop my Android application when I click closeButton. This is my code.

protected void onCreate(Bundle savedInstanceState) {

  this.setCon         


        
6条回答
  •  死守一世寂寞
    2020-11-27 06:22

    Why not to make a Shell-Call to ActivityManager?

    try {
          Runtime.getRuntime().exec("am force-stop com.me.myapp");
        } catch (IOException e) {
          e.printStackTrace();
        }
    

提交回复
热议问题