This code starts the activity:
Intent intent = new Intent(context, GameActivity.class);
intent.putExtra("load", true);
startActivity(intent);
This is how I try to get the intent in the new activity:
private Intent intent = this.getIntent();
I was told to try and include:
@Override
protected void onNewIntent(Intent intent) {
super.onNewIntent(intent);
setIntent(intent);
}
But it doesn|t help. After several crashes I added:
if (intent == null) Log.w("Intent", "Intent is null");
What am I doing wrong?
private Intent intent = this.getIntent();
在onCreate
或生命周期的另一个回调中调用getIntent()
。
尝试如下:
private boolean value =getIntent().getBoolean("load");
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.