getIntent() always returns null

后端 未结 2 1978
孤街浪徒
孤街浪徒 2021-01-23 09:26

This code starts the activity:

Intent intent = new Intent(context, GameActivity.class);
    intent.putExtra(\"load\", true);
    startActivity(intent);


        
相关标签:
2条回答
  • 2021-01-23 09:45
    private Intent intent = this.getIntent();
    

    Call getIntent() inside onCreate or in another callback of the life cycle.

    0 讨论(0)
  • 2021-01-23 09:49

    Try out as below:

    private boolean value =getIntent().getBoolean("load");
    
    0 讨论(0)
提交回复
热议问题