简体   繁体   English

在Application.onCreate代码之前调用NotificationListenerService

[英]NotificationListenerService called before Application.onCreate code

I have a NotificationListenerService implementation in my app. 我的应用程序中有一个NotificationListenerService实现。

It seems that certain things that I initialize in my Application class are not initialized when my NotificationListenerService runs. 似乎在我的NotificationListenerService运行时,我在Application类中初始化的某些事情没有初始化。 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. 另外,崩溃不是进入Crashlytics而是进入Google Play ,因此我假设也不发生crashlytics的初始化。

  • Is a service class extending NotificationListenerService not being called in an app's process? 是否在应用程序的流程中未调用扩展NotificationListenerService的服务类?
  • Is it called outside of the Application context? 是在Application上下文之外调用的吗?

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();
    }
}

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. 似乎Google Play中约有95%的崩溃报告来自名为Vivo 1601的设备,因此这很可能是该设备上Android的错误实现,或者是根源设备反复崩溃。

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. 由于这不是Crashlytics,因此我无法确定有多少唯一用户报告了此崩溃,但是可以肯定地说这不是Android或我的应用程序中的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Android Activity::onCreate 在 Application.onCreate 之前调用 - Android Activity::onCreate called before Application.onCreate 在BroadcastReceiver.onReceive(..)之前是否会调用Application.onCreate(Bundle)? - Will Application.onCreate(Bundle) be called before BroadcastReceiver.onReceive(..)? Application.onCreate被多次调用 - Application.onCreate called more than once Application.onCreate() 未在调试版本中调用 - Application.onCreate() not called in debug build 为什么 ContentProvider.onCreate() 在 Application.onCreate() 之前被调用? - Why does ContentProvider.onCreate() get called before Application.onCreate()? 确定调用Application.onCreate()的进程 - Determine by which process Application.onCreate() is called 如果应用程序闲置了数小时并被OS破坏,是否在Activity.onResume之前调用Application.onCreate? - Is Application.onCreate called before Activity.onResume if app has been idle for hours and destroyed by OS? 在Application.onCreate()上的BroadcastReceiver - BroadcastReceiver on Application.onCreate() 是否有Android注释要求在Application.onCreate期间调用方法? - Is there an Android annotation to require that a method be called during Application.onCreate? 应用程序可以在Application.onCreate()之前获取Fragment.onAttached()吗? - Can the app get Fragment.onAttached() before Application.onCreate()?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM