AndroidTV 获取通知图标
AndroidTV get notification icon
我正在尝试获取 AndroidTV 上的活动通知图标。我需要将其编码为 base64 并将其发送给本机反应。
图标存储为 blob 类型,解码后如下所示
android.graphics.drawable.Icon com.android.systemui/
这看起来只是图标的路径,但我需要获取真正的图标并将其编码为 base 64。
我正在这样检索数据:
private static final Uri NOTIF_CONTENT_URI = Uri.parse(
"content://com.android.tv.notifications.NotificationContentProvider/" +
"notifications");
final String[] projection = { TITLE, TEXT, SMALL_ICON};
Cursor c = _reactContext.getContentResolver().query(NOTIF_CONTENT_URI, projection, null,
null, null);
if (c != null && c.moveToFirst()) {
do {
String title = c.getString(c.getColumnIndex(TITLE));
String text = c.getString(c.getColumnIndex(TEXT));
byte[] smallIconBytes = c.getBlob(c.getColumnIndex(SMALL_ICON));
} while (c.moveToNext());
}
获取标题和文本工作正常,但将图标字节编码为 base64 returns
HgAAAGEAbgBkAHIAbwBpAGQALgBnAHIAYQBwAGgAaQBjAHMALgBkAHIAYQB3AGEAYgBsAGUALgBJAGMAbwBuAAAAAAACAAAAFAAAAGMAbwBtAC4AYQBuAGQAcgBvAGkAZAAuAHMAeQBzAHQAZQBtAHUAaQAAAAAALwUIAQAAAAAFAAAA
可以解码为
android.graphics.drawable.Icon com.android.systemui/
我怎样才能得到那个图标而不仅仅是路径?谢谢。
private static Icon getIconFromBytes(byte[] blob) {
Parcel in = Parcel.obtain();
Icon icon = null;
if (blob != null) {
in.unmarshall(blob, 0, blob.length);
in.setDataPosition(0);
icon = in.readParcelable(Icon.class.getClassLoader());
}
in.recycle();
return icon;
}
我正在尝试获取 AndroidTV 上的活动通知图标。我需要将其编码为 base64 并将其发送给本机反应。
图标存储为 blob 类型,解码后如下所示
android.graphics.drawable.Icon com.android.systemui/
这看起来只是图标的路径,但我需要获取真正的图标并将其编码为 base 64。
我正在这样检索数据:
private static final Uri NOTIF_CONTENT_URI = Uri.parse(
"content://com.android.tv.notifications.NotificationContentProvider/" +
"notifications");
final String[] projection = { TITLE, TEXT, SMALL_ICON};
Cursor c = _reactContext.getContentResolver().query(NOTIF_CONTENT_URI, projection, null,
null, null);
if (c != null && c.moveToFirst()) {
do {
String title = c.getString(c.getColumnIndex(TITLE));
String text = c.getString(c.getColumnIndex(TEXT));
byte[] smallIconBytes = c.getBlob(c.getColumnIndex(SMALL_ICON));
} while (c.moveToNext());
}
获取标题和文本工作正常,但将图标字节编码为 base64 returns
HgAAAGEAbgBkAHIAbwBpAGQALgBnAHIAYQBwAGgAaQBjAHMALgBkAHIAYQB3AGEAYgBsAGUALgBJAGMAbwBuAAAAAAACAAAAFAAAAGMAbwBtAC4AYQBuAGQAcgBvAGkAZAAuAHMAeQBzAHQAZQBtAHUAaQAAAAAALwUIAQAAAAAFAAAA
可以解码为
android.graphics.drawable.Icon com.android.systemui/
我怎样才能得到那个图标而不仅仅是路径?谢谢。
private static Icon getIconFromBytes(byte[] blob) {
Parcel in = Parcel.obtain();
Icon icon = null;
if (blob != null) {
in.unmarshall(blob, 0, blob.length);
in.setDataPosition(0);
icon = in.readParcelable(Icon.class.getClassLoader());
}
in.recycle();
return icon;
}