And*_*rew 5 android android-notifications android-framework
使用android 4.4我发现有些用户正在使用我已实现的notificationListenerService将停止工作.我自己也见过这个.
我从来没有设法在它发生的时候捕获任何日志,但即使进入通知访问部分并关闭和重新开启通知访问也无济于事.
有什么东西可以导致这种情况发生.我不确定我的应用程序是否崩溃并造成这种情况,但即使这样,重启监听器的唯一方法就是重启手机.还有另一种方法可以启动我的应用程序从侦听器服务接收通知吗?
我还得到用户在更新应用版本时遇到此问题的报告.
我已经尝试将日志放入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
Run Code Online (Sandbox Code Playgroud)
所以看起来有一个警告,然后停止服务并重新启动它(它发生在我的应用程序和我安装的其他应用程序使用通知访问查看正在停止的两个)
真的不知道我能做些什么来阻止这种停止
小智 1
这种方式可以重新启动,但是需要10s\xef\xbc\x81左右
\n\nprivate void toggleNotificationListenerService() {\n PackageManager pm = getPackageManager();\n pm.setComponentEnabledSetting(new ComponentName(this, com.xinghui.notificationlistenerservicedemo.NotificationListenerServiceImpl.class),\n PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP);\n\n pm.setComponentEnabledSetting(new ComponentName(this, com.xinghui.notificationlistenerservicedemo.NotificationListenerServiceImpl.class),\n PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP);\n\n }\nRun Code Online (Sandbox Code Playgroud)\n\n作者\xef\xbc\x9aHugo
\n\n链接\xef\xbc\x9a https://www.zhihu.com/question/33540416/answer/113706620
\n| 归档时间: |
|
| 查看次数: |
1772 次 |
| 最近记录: |