简体   繁体   English

Android使用Intent恢复活动

[英]Android resume activity with Intent

I've GOOGLE MAPS with some overlays on it. 我的GOOGLE MAPS上面有一些覆盖物。 The overlays are taken from a databse, so it takes some time to load the overlays. 覆盖图是从数据库获取的,因此需要花费一些时间来加载覆盖图。

Then I click to one overlay to bring another activity with info about that overlay. 然后,我单击一个叠加层,以进行另一项活动,其中包含有关该叠加层的信息。 This info is a new activity created via Intent. 此信息是通过Intent创建的新活动。

Then I want to go back to the map. 然后我想回到地图。 Ok, I click the button and it calls an new Intent to go back to the map. 好的,我单击按钮,它会调用一个新的Intent以返回到地图。

The map appears but the overlays don't. 地图会出现,但叠加层不会出现。

I figured out that one solution could be RESUMING the map instead of STARTING a new map with the intent. 我发现一种解决方案可能是恢复地图而不是有意启动新地图。

I tried to add a flag to resume the activity but it doesn't work. 我试图添加一个标志来恢复活动,但是它不起作用。

In the button I do: 在按钮中,我这样做:

Intent myIntent = new Intent(mContext,MapClass.class);
myIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
mContext.startActivity(myIntent);   

Please, any clues? 请提供任何线索?

Then I want to go back to the map. 然后我想回到地图。 Ok, I click the button and it calls an new Intent to go back to the map. 好的,我单击按钮,它会调用一个新的Intent以返回到地图。

Why ? 为什么呢 First, why do you need a button to go back ? 首先,为什么需要一个按钮才能返回? Just let the user go back using the device's Back button. 只需让用户使用设备的“后退”按钮返回即可。 Secondly, if you really need to use a back button (which I don't know why would you), why create a new intent to go back ? 其次,如果您确实需要使用后退按钮(我不知道您为什么会这么做),为什么还要创建一个新的返回意图? Just call finish() on the Activity with the button. 只需使用按钮在Activity上调用finish()即可。

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

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