Add null check to long press to avoid NPE

Experienced NPE when using this with the emulator. Added a null check to fix it.