Android 应调用onMessageReceived时的权限拒绝

Android 应调用onMessageReceived时的权限拒绝,android,wear-os,android-wear-data-api,Android,Wear Os,Android Wear Data Api,我正在关注这一点,并获得了一个可穿戴的Listener服务。我只是实现了onMessageReceived方法,没有更改任何其他内容 该服务的条目如下所示: <service android:name=".WearableRemoteCommandListener" android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE" android:enabled="true" and

我正在关注这一点,并获得了一个可穿戴的Listener服务。我只是实现了onMessageReceived方法,没有更改任何其他内容

该服务的条目如下所示:

<service android:name=".WearableRemoteCommandListener"
    android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"
    android:enabled="true"
    android:exported="true">
    <intent-filter>
        <action android:name="com.google.android.gms.wearable.BIND_LISTENER"></action>
    </intent-filter>
</service>
我尝试添加导出和启用属性,重新启动可穿戴设备,但异常再次发生。是否缺少许可证?我的设置有什么问题?

摆脱这一行

android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"

NotificationListenerService必须要求,以确保 只有系统才能绑定到它


你能把这行代码去掉并重新运行吗?这就是问题所在。现在它起作用了。你应该加上你的评论作为回答,这样我才能接受。
06-08 21:15:41.337      579-842/? W/ActivityManager﹕ Permission Denial: Accessing service ComponentInfo{net.bplaced.schlingel.wearabletest1/net.bplaced.schlingel.anmosela.WearableRemoteCommandListener} from pid=822, uid=10009 requires android.permission.BIND_NOTIFICATION_LISTENER_SERVICE
06-08 21:15:41.437      822-940/? W/WearableService﹕ ensureBindStarted: Permission denied connecting to net.bplaced.schlingel.anmosela.WearableRemoteCommandListener
    java.lang.SecurityException: Not allowed to bind to service Intent { act=com.google.android.gms.wearable.BIND_LISTENER cmp=net.bplaced.schlingel.wearabletest1/net.bplaced.schlingel.anmosela.WearableRemoteCommandListener }
            at android.app.ContextImpl.bindServiceCommon(ContextImpl.java:1793)
            at android.app.ContextImpl.bindService(ContextImpl.java:1757)
            at android.content.ContextWrapper.bindService(ContextWrapper.java:539)
            at com.google.android.gms.wearable.service.t.b(SourceFile:1157)
            at com.google.android.gms.wearable.service.t.a(SourceFile:1099)
            at com.google.android.gms.wearable.service.t.handleMessage(SourceFile:1077)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.os.HandlerThread.run(HandlerThread.java:61)
android:permission="android.permission.BIND_NOTIFICATION_LISTENER_SERVICE"