NotificationListenerService的startService返回null,并且服务无法启动

时间:2020-01-24 09:01:55

标签: android notification-listener

我有这样声明的NotificationListenerService:

<service
   android:name=".MyNotificationListenerService"
   android:label="@string/MyNotificationListenerServiceName"
   android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
   <intent-filter>
      <action android:name="android.service.notification.NotificationListenerService" />
   </intent-filter>
</service>

我是这样开始的:

Intent Myservice = new Intent(getApplicationContext(), MyNotificationListenerService.class);
if (startService(Myservice) == null) {
   //I get here!!!
}

它在大多数设备上都运行良好,但是由于某些原因,该应用程序永远无法启动该服务。它总是返回“ null”。 然后,我告诉用户转到Android设置>>搜索“通知访问”,并手动允许该服务,但该应用未显示在列表中。 但这在大多数设备中都已显示。 看起来有些设备没有该选项。报告使用该设备的最后一个用户:“荣誉-HRY-L21-HRY-LX1-HRY-LX1-华为”。它不是一款非常便宜的手机,而且我认为它不是“ LowRam”设备或Android Go设备。 这里的任何光将不胜感激。谢谢。

0 个答案:

没有答案
相关问题