TabGroupActivity startChildActivity - 暂停当前Activity
扩展TabGroupActivity,当我启动一个新的childActivity时:
public void startChildActivity(String Id, Intent intent) {
Window window = getLocalActivityManager().startActivity(Id,
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
if (window != null) {
activityIdList.add(Id);
setContentView(window.getDecorView());
}
}
如何将当前活动置于暂停状态?
因为当我以这种方式启动子活动后,当我重新启动它时,就会运行 on create 方法。我怎样才能避免这种情况?
找到一个解决方案是使用另一个标志:
Intent.FLAG_ACTIVITY_REORDER_TO_FRONT
但不确定这是否是最好的解决方案
P.PS 另一个解决方案是向 startChildActivity 方法添加一个布尔意图:
public void startChildActivity(String Id, Intent intent) {
intent.addExtra("resume", true);
Window window = getLocalActivityManager().startActivity(Id,
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
if (window != null) {
activityIdList.add(Id);
setContentView(window.getDecorView());
}
}
然后从子活动中检索它并检查该活动是否重新启动
Extending TabGroupActivity, when I start a new childActivity:
public void startChildActivity(String Id, Intent intent) {
Window window = getLocalActivityManager().startActivity(Id,
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
if (window != null) {
activityIdList.add(Id);
setContentView(window.getDecorView());
}
}
How can I put the current activity into the pause state?
Because after I start a child activity in this way, when I restart it, then the on create method is run. How can I avoid this?
Found one solution is to use another flag:
Intent.FLAG_ACTIVITY_REORDER_TO_FRONT
but not sure if it is the best solution
P.P.S
Another solution is to add an boolean intent to the startChildActivity method:
public void startChildActivity(String Id, Intent intent) {
intent.addExtra("resume", true);
Window window = getLocalActivityManager().startActivity(Id,
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
if (window != null) {
activityIdList.add(Id);
setContentView(window.getDecorView());
}
}
and then retrieve it from the child activity and check if the activity is restarted or not
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试将其放入清单文件中的活动标记中
它应该看起来像这样
Try putting this in activity tag in the manifest file
It should look something like this