如何在选项卡小部件内的活动组内从一个活动调用 startactivityforresult 到另一个活动
我有一个选项卡活动,在一个选项卡内有活动组。最初显示活动 A,从那里我想使用 startactivityforresult 调用活动 B。如何实现这一目标?
在我的活动 A 中,我正在这样做...
Intent i = new Intent(Entry.this, Child.class);
// Create the view using FirstGroup's LocalActivityManager
View view = GroupActivity.group.getLocalActivityManager()
.startActivity("child", i
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
.getDecorView();
// Again, replace the view
GroupActivity.group.replaceView(view);
虽然这会将我带到活动 B,但我无法从那里返回到活动 A。
I have a tab activity, and inside one tab I have activitygroup. Initially activity A is shown and from there I want to call activity B using startactivityforresult. How to achieve this?
in my activity A, I am doing this...
Intent i = new Intent(Entry.this, Child.class);
// Create the view using FirstGroup's LocalActivityManager
View view = GroupActivity.group.getLocalActivityManager()
.startActivity("child", i
.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP))
.getDecorView();
// Again, replace the view
GroupActivity.group.replaceView(view);
This though takes me to activity B, there is no way for me to return to activity A from there.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将 startActivity 更改为:
.startActivityForResult(i, .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
然后将此方法添加到 ActivityA:
然后当在 Activity B 上调用 finish() 时,您应该点击“OnActivityResult”方法。 调用:将 Intent 发送回主 Activity。
您还可以通过在 Activity B 上
Change startActivity to:
.startActivityForResult(i, .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
then add this method to ActivityA:
and then when finish() is called on Activity B you should hit the 'OnActivityResult' method. You can also send an intent back to main activity by calling:
on Activity B.