- A活動是SingleTask
B活動和C活性的標準,活動是SingleTask並且是任務的根源,頂級的reStrart活動是否已被刪除?
A - >乙 - > C,然後按Home鍵,再按下應用程序圖標,爲什麼B,C destory?爲什麼B首先破壞,C會在以後破壞?
<activity android:name=".Main1Activity" android:launchMode="singleTask"> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name="com.example.dell.taskdemo.Main2Activity" /> <activity android:name="com.example.dell.taskdemo.Main3Activity" />
公共類Main1Activity延伸AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
System.out.println("---1: onCreate " + getTaskId());
}
public void enter(View view) {
Intent intent = new Intent(this, Main2Activity.class);
startActivity(intent);
}
}
公共類Main2Activity延伸AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main2);
System.out.println("---2: onCreate " + getTaskId());
}
public void enter(View view) {
startActivity(new Intent(this, Main3Activity.class));
}
}
公共類Main3Activity擴展AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main3);
System.out.println("---3: onCreate " + getTaskId());
}
}
你能否添加開始** A **和** B **活動的代碼? – Alexander
用出來的代碼貼出來,我們只能給出模糊的答案... – sharan
謝謝!有代碼編輯,請解釋結果?爲什麼顯示A? –