Android 5.1 推送通知图标为空白 [英] Android 5.1 push notification icon is blank
问题描述
当使用 Parse 进行推送通知时,我们的应用程序始终显示应用程序的启动器图标.在最新的 Android 5.1 版本中,图标显示为空白(白色方块).
我尝试在元数据中设置图标:
<meta-data android:name="com.parse.push.notification_icon" android:resource="@drawable/noti_icon"/>
基于问题这里>
但似乎没有任何效果.有什么想法吗?
在 Android Lollipop 5.0 或更高版本下,您必须使用透明的白色图标.您可以扩展 ParsePushBroadcastReceiver 类并覆盖这两个方法,以使您的通知图标与这些 Android API 兼容.
@Override受保护的 int getSmallIconId(上下文上下文,意图意图){返回 R.drawable.your_notifiation_icon;}@覆盖受保护的位图 getLargeIcon(上下文上下文,意图意图){返回 BitmapFactory.decodeResource(context.getResources(), R.drawable.your_notifiation_icon);}
记得自定义您的代码以支持 Lollipop 和以前的 API.
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {返回 BitmapFactory.decodeResource(context.getResources(), R.drawable.your_notifiation_icon_lollipop);}别的{返回 BitmapFactory.decodeResource(context.getResources(), R.drawable.your_notifiation_icon);}
When using Parse for push notifications our app always displayed the application's launcher icon. In the latest Android 5.1 version, the icon appears to be blank (a white square).
I tried setting the icon in the meta data:
<meta-data android:name="com.parse.push.notification_icon" android:resource="@drawable/noti_icon"/>
Based on the question here
But nothing seems to work. Any ideas?
You must use a transparent and white icon under Android Lollipop 5.0 or greater. You can extend ParsePushBroadcastReceiver class and override the two methods to get your notification icon compatible with these Android APIs.
@Override
protected int getSmallIconId(Context context, Intent intent) {
return R.drawable.your_notifiation_icon;
}
@Override
protected Bitmap getLargeIcon(Context context, Intent intent) {
return BitmapFactory.decodeResource(context.getResources(), R.drawable.your_notifiation_icon);
}
Remember to customize your code to support Lollipop and previous APIs.
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
return BitmapFactory.decodeResource(context.getResources(), R.drawable.your_notifiation_icon_lollipop);
}
else{
return BitmapFactory.decodeResource(context.getResources(), R.drawable.your_notifiation_icon);
}
这篇关于Android 5.1 推送通知图标为空白的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!