check if intent has extras 1

check if intent has extras

Intent intent = getIntent();

if (intent.hasExtra("bookUrl")) {
    bookUrl = b.getString("bookUrl");
} else {
   // Do something else
}

Here is what the above code is Doing:
1. Get the intent that started this activity
2. Check if the intent has an extra with the key “bookUrl”
3. If it does, get the value of the extra and assign it to the variable bookUrl
4. If it doesn’t, do something else

Similar Posts