单个活动实例 [英] Single Instance of Activity
问题描述
My application has three activities say A -> 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).
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.
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.
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屋!