Не работает NotificationListenerService
Не вызываются onListenerConnected(),onNotificationPosted(), но при этом сам сервис запускается, onCreate() работает. В настройках андроид разрешен доступ к уведомлениям для приложения, тестировал на телефоне и эмуляторе с android 12.
Код службы:
class NLService : NotificationListenerService() {
val TAG = "NLService"
override fun onBind(intent: Intent): IBinder? {
return null
}
override fun onCreate() {
Log.i(TAG, "onCreate")
}
override fun onStartCommand(intent: Intent?, flags: Int, startId: Int): Int {
Log.d(TAG, "onStartCommand")
return super.onStartCommand(intent, flags, startId)
}
override fun onListenerConnected() {
Log.d(TAG, "onListenerConnected")
}
override fun onNotificationPosted(sbn: StatusBarNotification?) {
Log.d(TAG, "onNotificationPosted")
}
}
Манифест:
<service
android:name=".Services.NLService"
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"
android:exported="true"
android:enabled="true">
<intent-filter>
<action android:name="android.service.notification.NotificationListenerService" />
</intent-filter>
</service>