开发者

Which way is true for Exit from app include IF method?

开发者 https://www.devze.com 2023-03-16 02:06 出处:网络
How we can exit from app incl开发者_如何学编程ude if method , like this method but it\'s not true :

How we can exit from app incl开发者_如何学编程ude if method , like this method but it's not true :

if (ClassName.this.finish(); == true) {

//code..

}


Still don't know, what you want to achieve, here are some suggestions:

If you want to finish the activity after some condition has become true:

if (activityShouldFinish() == true) {
  ActivityClassName.this.finish();
}

Maybe you want to do something before the acitivty is finished (famous last words). In this case, override the finish method:

@Override
public void finish() {
  doFamousLastWords();
  super.finish();
}


 @Override
        public void onDestroy() {
          super.onDestroy();
            //Write your code here

      }


You can also kill your process..

 @Override
  public void onDestroy() {
      //Any clean up you wanted to do
       super.onDestroy();
      //you can completely kill your process.
      android.os.Process.killProcess(android.os.Process.myPid()) ;
  }


You have an extra semicolon.

if (ClassName.this.finish() == true) {

//code..

}
0

精彩评论

暂无评论...
验证码 换一张
取 消