Can i give functionality of a forward button in my android app. In case of web app, the URLS and session id is stored in the stack so we can provide this functionality. But can we provide a similar 开发者_Python百科kind of functionality in our mobile app using activities.If yes then how and what would be the implications of the same.
if i don't kill my activities, then wouldn't it create memory issues??
Thanks..
Yeah I think it would be pretty simple.
So if you are working with Android 2.0 There is a function,
there is a function in Activity called, onBackPressed(). If you have all your activities override this and do something like:
public void onBackPressed() {
Intent intent = getIntent();
MyAccessableStorageFacility.storeForwardIntent(intent);
super.onBackPressed();
}
public void onCreateOptionsMenu(Menu menu) {
menu.add("Forward").setIntent(MyAccessableStorageFacility.getLastIntent());
super.onCreateOptionsMenu(menu);
}
If you don't have Android 2.0, just override the onKeyPressed method instead of the onBackPressed and look for the keycode of the back button and write the same code to save the last intent.
First, I think you would need to set the launchMode
of each activity to SingleTop
. Second, you would need to stop the back button from calling onDestroy
and get it to do startActivity
with an Intent
set to the class of the Activity
below.
精彩评论