I had 3 activities in an android application. The application will exit when I press back button in each activity. Using the following code.
When I press back from the third activity, the application exits fine but when I relaunch the application by clicking the app icon, then the third activity will launch again. But I need to launch my main activity at the time of such "relaunch".
I tried write the code on "onResume" but not working.
@Override
public boolean onKeyDown(int keyCode, KeyEvent event)
{
if (keyCode == KeyEvent.KEYCODE_BACK)
{
moveTaskToBack(true);
return true;
}
return super.onKeyDown(keyCode, event);
}
Please help me. Thanks in advance