App crashes on received gcm message when it's closed
问题 When my app is closed (i.e swiped off by the user from the App Switching menu), it crashes in onMessageReceived() . Here's onMessageReceived() : @Override public void onMessageReceived(String from, Bundle data) { String message = data.getString("message"); from = data.getString("sender"); File notificationsFile = Constants.getNotificationsFlagFile(); ... } It crashes on that last line, giving a null pointer exception : 08-13 21:15:25.535 23201-23216/com.example.myapp E/AndroidRuntime﹕ FATAL