2013-11-25 29 views
5

with Android 4.4私が実装したnotificationListenerServiceを使用しているユーザーがいることがわかりました。私は実際に自分自身もこれを見てきました。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 

、サービスを停止することになるだろう警告がありますようだから、それが見えます: これが起こっていたし、ログの興味深い部分があることになりそうだ後、私は、バグレポートをキャプチャそれを再起動する(私のアプリケーションと、私がインストールした他のアプリケーションでは、2つの停止中の通知アクセスを使用している)。

この停止を停止するために私ができることは本当にわからない

答えて

1

この方法は、それを再起動することができますが、それは10秒程度必要

private void toggleNotificationListenerService() { 
     PackageManager pm = getPackageManager(); 
     pm.setComponentEnabledSetting(new ComponentName(this, com.xinghui.notificationlistenerservicedemo.NotificationListenerServiceImpl.class), 
       PackageManager.COMPONENT_ENABLED_STATE_DISABLED, PackageManager.DONT_KILL_APP); 

     pm.setComponentEnabledSetting(new ComponentName(this, com.xinghui.notificationlistenerservicedemo.NotificationListenerServiceImpl.class), 
       PackageManager.COMPONENT_ENABLED_STATE_ENABLED, PackageManager.DONT_KILL_APP); 

    } 

投稿者:ヒューゴを

リンク:https://www.zhihu.com/question/33540416/answer/113706620

関連する問題