Phone at 0% battery, shuts down, app crashes in the background because ChatManager.getInstance() causes a RuntimeException if the Instance is Null, doesn't return Null, so the code in ShutdownReceiver "onReceive" causes the app to crash:
@Override
public void onReceive(Context context, Intent intent) {
if (Intent.ACTION_SHUTDOWN.equals(intent.getAction())) {
Log.i(TAG, "System shutting down");
// disconnect the current user when the phone shutdown
if(ChatManager.getInstance() != null) {
ChatManager.getInstance().getMyPresenceHandler().dispose();
}
}
}
}
The crash: java.lang.RuntimeException: instance cannot be null. call start first.
at org.chat21.android.core.ChatManager.getInstance(ChatManager.java:409)
at org.chat21.android.core.receivers.ShutdownReceiver.onReceive(ShutdownReceiver.java:23)
Phone at 0% battery, shuts down, app crashes in the background because ChatManager.getInstance() causes a RuntimeException if the Instance is Null, doesn't return Null, so the code in ShutdownReceiver "onReceive" causes the app to crash:
@Override public void onReceive(Context context, Intent intent) { if (Intent.ACTION_SHUTDOWN.equals(intent.getAction())) { Log.i(TAG, "System shutting down");
}
The crash: java.lang.RuntimeException: instance cannot be null. call start first. at org.chat21.android.core.ChatManager.getInstance(ChatManager.java:409) at org.chat21.android.core.receivers.ShutdownReceiver.onReceive(ShutdownReceiver.java:23)