Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ShutdownReceiver crash when phone runs out of battery, Android #36

Open
ivankostadinovic opened this issue Oct 18, 2019 · 0 comments
Open

Comments

@ivankostadinovic
Copy link

ivankostadinovic commented Oct 18, 2019

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant