【发布时间】:2011-12-06 02:19:36
【问题描述】:
一个活动是一个单实例活动。
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
public class A extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle("A");
startActivity(new Intent(this, B.class));
}
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
testLog("new Intent A");
}
private void testLog(String string) {
Log.d("test", string);
}
@Override
protected void onDestroy() {
super.onDestroy();
testLog("destroy A");
}
}
B 活动是标准活动。
在正常情况下 A->B。用户动作后退操作,B销毁。用户再次按下,A 破坏。没错。
但在另一种情况下:A->B。用户操作主页按钮。当用户重启任务时,android框架调用A的onNewIntent()。
为什么?我的意思是活动堆栈应该是这样的:
-B
-A
为什么android框架将intent路由到A?
【问题讨论】:
-
您介意发布您的清单吗?我认为您将其作为启动器的默认设置。
-
更好的是,只需回答:“A”是清单中的默认/启动器活动吗?
-
android manifest 很简单。像这样:
-
不,A 不是默认启动器。
-
请稍候,我正在写答案,因为我相信我完全了解您的想法以及为什么您无法理解下面已经写好的答案。
标签: android