getString() returns null if the key isn't found. Save a few lines and just do String contact = extras.getString("contact");