美文网首页
为intent添加flag

为intent添加flag

作者: OT1087 | 来源:发表于2017-02-14 17:31 被阅读0次

    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

          本文链接:https://www.haomeiwen.com/subject/pbxfwttx.html