活动的单个实例 [英] Single Instance of Activity
问题描述
我的应用程序有三个活动说 A - > B-> ç
。
My application has three activities say A -> B-> C
.
活动A从另一项活动名为通过 startActivityForResult()
。活性B和C也称为类似。我必须调用从通知栏还活性的(如果有一些具体的通知)。
Activity A is called from another activity through startActivityForResult()
. Activity B and C are also called similarly. I have to call activity A from notifications bar also (if there is some specific notification).
现在,如果我目前的活动B或C,和我点击通知栏,并调用的活动时,该应用程序进入到活动只有A和输入的数据通过activites B或C不存在。
Now, if currently I am in activity B or C, and I click on Notification bar, and call the activity A, the app goes to Activity A only and data entered through activites B or C do not persist.
我不希望这样的行为。我想,如果我点击的通知,它应该重定向到目前唯一的屏幕。能有人帮助。 (我提到活动:launchMode
为 SingleTask
)。
I don't want such behavior. I want that if I click on Notification, it should redirect to current screen only. Can some one help. (I mentioned activity:launchMode
as SingleTask
).
推荐答案
您可能能够使用一个静态变量来确定其他数据。我不知道有多少,或者您正在寻找什么类型的数据与其他活动来访问,但。
You may be able to use a static variable to determine other data. I am not sure how much or what type of data you are looking to access from the other Activities, though.
也写入持久性存储可能工作,但同样 - 什么样的数据要存储的模糊性,以及如何使人们难以回答。只要写/读持久存储在 onResume
和 onSuspend
每项活动的methdod(或创建超Activity类和扩展它的A,B和C。
Also writing to persistent storage may work, but again - the vagueness of what data you are storing and how makes it difficult to answer. Just write/read the persistent storage in the onResume
and onSuspend
methdod of each Activity (or create super Activity class and extend it for A, B and C.
这篇关于活动的单个实例的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!