建议你看看activity 生命周期。
onCreate() Called when the activity is first created. Always followed by onStart().
onStart() Called when the activity is becoming visible to the user.
onCreate() Called when the activity is first created. Always followed by onStart().
onStart() Called when the activity is becoming visible to the user.
我有一后台服务,收到某一消息,会启动这个程序,一般来说第二次启动,不会再调用onCreate,而我的执行确有调用
<activity android:name="XXX" android:launchMode="singleTask"> </activity>
Intent i = new Intent(context, XXX.class);
i.addCategory(Intent.CATEGORY_LAUNCHER);
i.setAction(Intent.ACTION_MAIN);
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.startActivity(lockscreen);