单个活动实例 [英] Single Instance of Activity

查看:25
本文介绍了单个活动实例的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆