简体   繁体   English

来自Android活动的LaunchMode singleTask

[英]LaunchMode singleTask from android activity

I added to a activity android:launchMode="singleTask" to escape a memory consumption problem (Explanation: that activity contained bitmaps & lets say i had that activity in the backstack, when i received intent with my broadcast & opened that activity -> i had 2 of the same activity consuming memory due to their bitmaps) 我添加了一个活动android:launchMode="singleTask"来避免内存消耗问题(说明:该活动包含位图,并且可以说我在广播中收到意图并在后台打开了该活动->我由于它们的位图,有2个相同的活动消耗了内存)

<activity android:name=".activity.XActivity" android:launchMode="singleTask">

but now i have other problem, that activity is the main activity, so each click on app icon restarts app (in the sense that without this attribute, click on app icon will bring to front the current activity of the app) 但现在我还有其他问题,该活动是主要活动,因此每次单击应用程序图标都会重新启动应用程序(从某种意义上说,如果没有此属性,则单击应用程序图标将使该应用程序的当前活动处于最前面)

How can i escape this? 我该如何逃脱? I've also tried some combinations of flags when sending intent.. but not much success.. 发送意图时,我也尝试过标志的一些组合..但是成功不多。

这可能对您有帮助。

          notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP |Intent.FLAG_ACTIVITY_SINGLE_TOP);

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

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