【问题标题】:application not listed in notification access Setting (Android)通知访问设置中未列出的应用程序 (Android)
【发布时间】:2016-10-12 11:02:01
【问题描述】:

我的应用未在通知访问设置屏幕中列出...

我在 ma​​nifest.xml 中添加了此权限 BIND_NOTIFICATION_LISTENER_SERVICE

通过调用此意图打开通知访问设置屏幕startActivity(new Intent("android.settings.ACTION_NOTIFICATION_LISTENER_SETTINGS"));

感谢任何人实施...

【问题讨论】:

    标签: android android-studio notifications


    【解决方案1】:

    我也遇到了这个问题,我错误地将服务标签放在应用程序标签之外:

    <?xml version="1.0" encoding="utf-8"?>
    

    <service android:name=".TELNotificationListening"
        android:label="@string/service_name"
        android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
        <intent-filter>
            <action android:name="android.service.notification.NotificationListenerService" />
        </intent-filter>
    </service>
    
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/Theme.AppCompat.Light.NoActionBar" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
    
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
    

    我通过将服务标签放在应用程序标签中解决了这个问题,如下所示:

    <?xml version="1.0" encoding="utf-8"?>
    

    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/Theme.AppCompat.Light.NoActionBar" >
        <activity
            android:name=".MainActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
    
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <service android:name=".TELNotificationListening"
            android:label="@string/service_name"
            android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE">
            <intent-filter>
                <action android:name="android.service.notification.NotificationListenerService" />
            </intent-filter>
        </service>
    </application>
    

    在我的例子中,您需要创建一个扩展 NotificationListenerService 的类,我将其命名为 TELNotificationListening。你把你的类名放在服务标签中的 android:name="" 中。

    为了扩展 NotificationListenerService,您的最低 SDK 必须设置为 21。

    一旦你扩展了 NotificationListenerService,你就可以覆盖它的方法!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-12-17
      • 1970-01-01
      • 1970-01-01
      • 2012-02-15
      • 2016-11-02
      • 1970-01-01
      • 2022-11-13
      • 1970-01-01
      相关资源
      最近更新 更多