为intent添加flag

intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) 这样启动时会为它创建一个新的任务栈

singleTask模式时 会将在其之上的所有活动都出栈 之后会调用onNewIntent方法

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

processExtraData();

}

protected void onNewIntent(Intent intent) {

super.onNewIntent(intent);

setIntent(intent);//must store the new intent unless getIntent() will return the old one

processExtraData()

}

private void processExtraData(){

Intent intent = getIntent();

//use the data received here

}

你可能感兴趣的:(为intent添加flag)