Is there any way to check if an extra has been passed when starting an Activity?
I would like to do something like (on the onCreate()
in the Activity):
Bundle extras = getIntent().getExtras();
String extraStr = extras.getString("extra");
if (extraStr == null) {
extraStr = "extra not set";
}
But this is throwing a java.lang.NullPointerException
.
Thank you.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…