Thursday 10 May 2012


How to force stop android application ?

This finishes 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 would like to force close my Android applicationwhen i click close button/This is my code.
protected void onCreate(Bundle savedinstanceState){

 setContentView(R.layout.main);


closeButton =(Button)findViewById(R.id.closebtn);


closeButton.setOnClickListener(new OnClickListener(){


@Override

public void onClick(View v){
    finish();                   //for stopping particular Current Activity.
}});


@Override

protected void onDestroy(){
     super.onDestroy();

//This line is added to kill whole application forcefully or Forcefully stop.      android.os.Process.killProcess(android.os.Process.myPid());  


}}