假设有三个活动,显示顺序是a-> b-> c。
现在,我想在Activity
c完成一些操作后直接恢复活动a。
直接从Activity
c恢复Activity
a,但创建一个新的Activity a实例。
答案 0 :(得分:2)
FLAG_ACTIVITY_CLEAR_TASK
来执行此操作:"If set in an Intent passed to Context.startActivity(), this flag will cause any existing task that would be associated with the activity to be cleared before the activity is started"。
或者您可以在活动a finish();
onPause
如果您想恢复它,那么您只需拨打startActivity(new Intent(Parent.this, ActivityA.class));
或任何代码
答案 1 :(得分:2)
BroadcastReceiver
的{{1}}方法中的onResume()
:BroadcastReceiver receiverFinish = null;
finish()
@Override
protected void onResume() {
super.onResume();
if(receiverFinish!=null){
unregisterReceiver(receiverFinish);
}
receiverFinish=new BroadcastReceiver() {
//完成b活动
Intent intent = new Intent(“finish.activity”); sendBroadcast(意向);
//完成c活动
结束();