How to achieve the following flow in android app?
My app receives a push notification and one of its activity gets launched. Now,
eg Activities A-->B--->C
Now the weirdness appears, pressing back is taking the user to same activity that was launched on notification click, in this case its taking the user to 'C'
I do not want this flow..pressing back key on main activity should exit the app.
any help?
Override the back button to do your desired function:
@Override
public void onBackPressed() {
Your function here.
super.onBackPressed();
}
And also you can add flags to your intent while calling respective activiies:
1.FLAG_ACTIVITY_NO_HISTORY
用这个-
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if ((keyCode == KeyEvent.KEYCODE_BACK))
{
finish();//do ur task
}
//same check for home screen key and do u task
return super.onKeyDown(keyCode, event);
}
链接地址: http://www.djcxy.com/p/26170.html
上一篇: 从前台引回活动