当父活动停止完成子活动

编程入门 行业动态 更新时间:2024-10-19 01:29:31
本文介绍了当父活动停止完成子活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有一个在我的节目A1一项活动。 在A1的onCreate我使用意图调用Android的活动(A2):

There is one activity in my program "A1". In A1 onCreate i use intent to call android's activity ("A2"):

Intent contactPickerIntent = new Intent(Intent.ACTION_PICK, ContactsContract.CommonDataKinds.Phone.CONTENT_URI); startActivityForResult(contactPickerIntent, 1010);

当用户选择一个联系人,我想用在A1联系人信息。 一切都很好,但是......

when user picks a contact i want to use contact's information in A1. Everything is ok, but...

当我使用Home键,在A2,A1和A2 STIL在内存中,如果OS杀死A1(或者我可以从任务管理器做到这一点),A2被STIL运行,当我开始我的节目,我看到一个老A2,而当我拿起一个接触我看不到导致A1,因为新的A1开始,它需要新的A2。

When i use "home button" in A2, A1 and A2 stil in memory, and if OS kill A1 (or i can do it from task manager), A2 is stil running and when i start my program i see an OLD A2, and when i pick a contact i cant see result in A1, because NEW A1 is started and it calls for NEW A2.

现在的问题是:我怎么能杀A2,当有人杀死A1从内存

The question is: how can i kill A2, when somebody kills A1 from memory.

推荐答案

您只需调用父活动finishActivity(CHILD_ACTIVITY_REQUEST_CALL)中的onStop()方法。

You can just call finishActivity(CHILD_ACTIVITY_REQUEST_CALL) in the onStop() method of your parent activity.

在你的情况:

public void onStop(){ finishActivity(1010); }

更多推荐

当父活动停止完成子活动

本文发布于:2023-11-27 04:00:18,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1636493.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!