开发者

How to reuse intents in Android

Hello All: I am creating an application in which I am using menus on every screen for the user to navigate. In my application, I have Screen1--> comes as home screen when the user logs in Screen2--> user goes to this screen to perform some operations. Now on Screen2 I want to have menu option to let the user go to home screen. But to start the activity we do

startActivity(new Intent(Home.this, Screen2.class));

But, I want to use the existing home screen which was created when the used logged in and then using onresume metho开发者_StackOverflow社区d I can update the home screen.

Can anybody please tell me how to use the existing intents or activity to provide menu options? Thanks Ashwani


Ashwani,

I believe this can be done with a setFlags() call on your Intent using the FLAG_ACTIVITY_REORDER_TO_FRONT flag. If screen 1 still exists it will bring it to the foreground. The documentation doesn't seem to specify, but I assume it launches a new Activity of Screen 1 was killed.


Take a look at android:launchMode attribute of element. Is "singleTop" launch mode is what you mean by "use existing home screen"? If you use "singleTop" the activity is not recreated, but receives onNewIntent() signal.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜