我可能会对调度的工作方式感到有些困惑,我希望有人能够纠正我,或者告诉我,我是对的。
首次启动应用时,系统会根据清单中的指定启动活动Main Activity
。
(...)
Main Activity
启动Secondary Activity
然后暂停,而后者则会暂停。
(...)
Secondary Activity
到达启动intentservice的最后一条指令,表示服务在另一个线程上启动并自行运行。 Secondary Activity
到达终点并停止,Main Activity
恢复执行。
我不考虑任何外部操作系统干预。
我错过了什么吗?
编辑:Secondary Activity
代码
public class SecondaryActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Intent mis = new Intent(this,MyIntentService.class);
this.startService(mis);
finish();
}
}
答案 0 :(得分:1)
Can you please a give a more detailed information about how the SecondaryActivity
ends and stops are you calling finish() on it after its execution is done or calling the MainActivity
explicitly?
Activity do maintain a stack when you call an activity from an intent that activity is added to stack and unless and untill you do not finish the activity it wont get to the FirstActivity in your case MainActivity