【发布时间】:2018-09-21 21:13:59
【问题描述】:
我已在我的应用程序中添加了 android 可访问性,它在 pre oreo 设备上运行良好,但在 oreo 中我无法接收应用程序的第二次通知。
我只能接收应用程序的第一个通知,无法接收该应用程序的第二个通知。如果我将清除通知托盘中的通知,那么我将能够收到第一个通知,而第二个则没有收到。
例如
- 从whatsapp收到通知1,服务可以读取它
- 从whatsapp收到通知2,服务无法读取它
- 收到来自 Gmail 的通知 3,服务可以读取它
- 收到来自 Gmail 的通知 4,服务无法读取它
- 从whatsapp收到通知5,服务无法读取它
简而言之,从应用程序的 oreo 中忽略第二次以后的通知可访问性。
我的辅助功能代码,
public class NotificationService extends AccessibilityService {
@Override
public void onAccessibilityEvent(AccessibilityEvent evt) {
Toast.makeText(this, "Got event from " + evt.getPackageName(),
Toast.LENGTH_SHORT)
.show();
}
@Override
public void onInterrupt() { }
}
我的清单文件:
<application>
<activity
android:name=".MyActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<service android:name=".NotificationService" android:enabled="true"
android:permission="android.permission.BIND_ACCESSIBILITY_SERVICE" >
<meta-data
android:name="android.accessibilityservice"
android:resource="@xml/accessibility_service_config" />
<intent-filter>
<action android:name="android.accessibilityservice.AccessibilityService" />
</intent-filter>
</service>
</application>
【问题讨论】:
-
你能详细说明问题吗?
-
我正在更新相关示例。
-
请检查我的答案。
标签: android accessibility accessibilityservice