开发者

Android - Passing the main activity around

开发者 https://www.devze.com 2023-04-09 19:48 出处:网络
I have a several activities in my app. The main activity (activity1) extends ActivityGroup (I need to support 2.2 and above, so I cant use fragments).

I have a several activities in my app. The main activity (activity1) extends ActivityGroup (I need to support 2.2 and above, so I cant use fragments).

The main activity1 creates activity2, which in turn creates activity3. But when creating activity3 I 开发者_运维问答want activity1 to create it, not activity2.

How do you pass the main activity around between activities?

Thanks


A better way is to use startActivityForResult() in avtivity1 to statrt activity2.

and when you want activity3 just finish activity2 and in activity1 override

onActivityResult() and start Activity3. passing activity instance is not better idea

since that Activity may get killed when at background and thus susceptible to throw an

Exception.

0

精彩评论

暂无评论...
验证码 换一张
取 消