使用 android 4.4,我发现一些用户正在使用我实现的 notificationListenerService 将停止工作。这个其实我自己也看到了。
我从来没有设法在它发生时捕获任何 logcat,但即使进入通知访问部分并关闭并重新打开通知访问也无济于事。
有什么东西可以导致这种情况发生。我不确定我的应用程序是否崩溃并导致此问题,但即使是这样,重启监听器的唯一方法似乎是重启手机。是否有另一种方法可以启动我的应用程序从侦听器服务接收通知?
我还收到有关用户在更新应用程序版本时遇到此问题的报告。
我已经尝试将日志放入 onCreate/onDestroy 方法中,以查看它停止时是否记录了任何内容,但是调用了 onUnbind、onDestroy,但是没有为这两种方法输入任何内容,所以我猜它们一旦停止就不会被调用.
编辑: 发生这种情况后,我捕获了一个错误报告,日志中有趣的部分看起来是:
12-30 15:33:58.731 16194 16194 W ContextImpl: Calling a method in the system process without a qualified user: android.app.ContextImpl.sendOrderedBroadcast:1192 android.app.ContextImpl.sendOrderedBroadcast:1183 android.content.ContextWrapper.sendOrderedBroadcast:390 com.android.settings.applications.ProcessStatsDetail.checkForceStop:314 com.android.settings.applications.ProcessStatsDetail.onResume:108
12-30 15:33:58.741 780 780 V NotificationService: disabling notification listener for user 0: ComponentInfo{com.example.android.navigationdrawerexample/com.example.android.navigationdrawerexample.NotificationListener}
12-30 15:33:58.741 780 780 V NotificationService: disabling notification listener for user 0: ComponentInfo{lovetere.flashme/lovetere.flashme.accessibilityservice.ServicePostKitKat}
12-30 15:33:58.741 780 780 V NotificationService: enabling notification listener for user 0: ComponentInfo{com.example.android.navigationdrawerexample/com.example.android.navigationdrawerexample.NotificationListener}
12-30 15:33:58.741 780 780 V NotificationService: enabling notification listener for user 0: ComponentInfo{lovetere.flashme/lovetere.flashme.accessibilityservice.ServicePostKitKat}
12-30 15:33:58.751 1171 1171 D MyApp:NotificationListener: [NotificationListener] onDestroy
所以看起来有一个警告,然后会停止服务并重新启动它(它发生在我的应用程序以及我安装的另一个应用程序中,它使用通知访问查看两个正在停止的应用程序)
真的不知道我能做些什么来阻止这种停止