简体   繁体   English

恢复活动Android

[英]Resuming Activity Android

I have 4 activities, ABCDA is Menu and it's contained from 3 buttons that start other 3 activities, BC D. What I want, I want when I start BCD activity and decide to go to menu, to show Menu. 我有4个活动,ABCDA是“菜单”,它包含从启动其他3个活动(BC D)的3个按钮中。我想要的是,当我开始BCD活动并决定转到菜单时显示“菜单”。 It's working but there is a problem. 它正在工作,但是有问题。 Always when I go back to Menu, there is a Copy of Menu Activity. 总是在我回到菜单时,有一个菜单活动副本。 So how can I set it to resume activity not create new one? 那么,如何设置它以恢复活动而不创建新活动呢? But Without destroying it. 但不破坏它。

Without any code, its a little unclear what your problem is but I think what you want is to set an Intent.Flag . 没有任何代码,它有点不清楚您的问题是什么,但是我认为您想要的是设置Intent.Flag When starting the Activity add this flag to your Intent 启动Activity将此标志添加到您的Intent

Intent i = new Intent(CurrentActivityName.this, MenuActivity.class);
i.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);  // set the flag
startActivity(i);[

and don't call finish() in your menu Activity . 并且不要在菜单Activity调用finish()

Intent Docs 意向文档

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM