Add null pointer check before accessing the intent's extras