【发布时间】:2021-05-07 13:42:02
【问题描述】:
我已经实现了一种使用 NotificationContentProvider 获取通知的方法。这是我正在使用的代码
private static final Uri NOTIF_COUNT_CONTENT_URI = Uri.parse("content://com.android.tv.notifications.NotificationContentProvider/notifications/count");
private static final String COLUMN_COUNT = "count";
...
private int count;
Cursor c = context.getContentResolver().query(NOTIF_COUNT_CONTENT_URI, null, null, null, null);
if (c != null && c.moveToFirst()) {
int index = data.getColumnIndex(COLUMN_COUNT);
count = data.getInt(index);
}
if (c != null) {
c.close();
}
我遇到异常的问题
java.lang.SecurityException: App does not have permission: android.permission.ACCESS_NOTIFICATIONS
我尝试在清单中添加此权限并在运行时询问,但这些都不起作用。如何获取通知计数?我还需要收到看不见的通知,但我还没有找到方法
【问题讨论】:
标签: android android-tv