Hi i want to know how to close an application in Android.
Actually i am having idea by using the finish() method we can close present activity..
But what i want is, the following code defines remaining…
Main.java
Handler handle=new Handler();
handle.postDelayed(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
startActivity(new Intent(ZzzzzProjActivity.this,Second.class));
}
}, 3000);
Second.java
/*** same above code***/
Third.java
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
if(keyCode == KeyEvent.KEYCODE_BACK)
{
Toast.makeText(getApplicationContext(), "backbutton", 30).show();
finish();
}
return super.onKeyDown(keyCode, event);
}
As per the following code after coming to Third.java, when i click back button it is navigating back to Second.java page. But what i want is my applications needs to close totally. Can anyone help me with this….
for Achive that you should finish the current Activity when you call another Activity from Current one, like when you call second.class from first one you should finish first one and so on…,
i.e when you call another activity.class then you should finish the currentActivity.class by
like
CurrentActivity.this.finish();