Breaking News
Loading...

How to force stop my android application programatically ?

8:06 PM


This finishs my application. But if I go to
'Settings -> Applications -> Manage applications -> , I can see the 'Force Stop' button is enabled
(This means my application was not stopped completely ?). How can I finish my android application completely and makes 'Force Stop' button disabled in the 'Settings' ? From my limited experience, only when an 'Exception' (ex. Nullpointerexception) occurs in the application and it stops abnormally, my application looks like finished completely and the 'Force Stop' button looks disabled.






I'd like to force stop my android applicataon when I click closeButton. This is my code.



protected void onCreate(Bundle savedInstanceState) {



this.setContentView(R.layout.layoutxml);



this.closeButton = (Button)this.findViewById(R.id.close);



this.closeButton.setOnClickListener(new OnClickListener() {



@Override



public void onClick(View v) {



finish(); // for stopping Current Activity



}



});


// add this line for Removing Force Close

@Override
protected void onDestroy() {
// closing Entire Application
android.os.Process.killProcess(android.os.Process.myPid());
super.onDestroy();
}
}






0 komentar:

Post a Comment

 
Toggle Footer