Use the Intent.hasExtra(String name)
to check if an extra with name
was passed in the intent.
Example:
Intent intent = getIntent();
if (intent.hasExtra("bookUrl")) {
bookUrl = b.getString("bookUrl");
} else {
// Do something else
}
Also, use Intent.getStringExtra(String name)
directly on the intent to handle the NullPointerException
if no extras were passed.