安卓桌面消息获取,角标数量显示

获取到环信发送的数据后,以极光推送给推送方式完成消息通知,但是小米手机上,角标数量不变化。百度了很久发现了这个方法。感谢这个博主:http://blog.csdn.net/u013334392/article/details/54089205 他写的比较详细,但是我只用到了三行就完成了。做个记号..
Notification.Builder builder = new Notification.Builder(this)
.setContentTitle(“title”).setContentText(“text”).setSmallIcon(R.drawable.icon;
Notification notification = builder.build();//生成通知
try {
*//import java.lang.reflect.Field;
//import java.lang.reflect.Method;*
Field field = notification.getClass().getDeclaredField(“extraNotification”);
Object extraNotification = field.get(notification);
Method method = extraNotification.getClass().getDeclaredMethod(“setMessageCount”, int.class);
method.invoke(extraNotification, mCount);//mCount为实时获取的角标未读消息数量
} catch (Exception e) {
e.printStackTrace();
}
mNotificationManager.notify(0,notification);//0为通知ID

//小米亲测可用

修改文件在环信三方依赖库的EaseNotifier文件

你可能感兴趣的:(安卓桌面消息获取,角标数量显示)