NotificationListenerService called before Application.onCreate code

175 Views Asked by At

I have a NotificationListenerService implementation in my app.

It seems that certain things that I initialize in my Application class are not initialized when my NotificationListenerService runs. Also, crashes are not coming into Crashlytics, but into Google Play instead, so I'm assuming the initialization of crashlytics isn't happening as well.

  • Is a service class extending NotificationListenerService not being called in an app's process?
  • Is it called outside of the Application context?

Simplified implementation of my code:

public class MyApplication extends Application {
    @Override
    public void onCreate() {
        super.onCreate();
        Settings.init(this);
    }
}

public class MyNotificationService extends NotificationListenerService {
    @Override
    public void onCreate() {
        super.onCreate();
        new AsyncTask<Void, Void, Void>() {
            @Override
            protected Void doInBackground(Void... params) {
                if (Settings.getSomething()) { // Crash! settings not initialized
                    ...
                }
            }
        }.execute();
    }
}
1

There are 1 best solutions below

0
On

It seems ~95% of reported crashes in Google Play come from a device called Vivo 1601, so this is most likely a bad implementation of Android on the device, or a rooted device repeatedly crashing.

Since this is not Crashlytics, I can't tell how many unique users have reported this crash, but it is safe to say It's not an issue in Android or my app.