Which way is true for Exit from app include IF method?
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..
}
精彩评论