温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

Android推送通知

发布时间:2020-10-12 14:26:34 来源:网络 阅读:297 作者:jdijfijf 栏目:移动开发

 Bitmap btm = BitmapFactory.decodeResource(getResources(),

R.drawable.ic_launcher);

NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(

KitActivity.this).setSmallIcon(R.drawable.ic_launcher)

.setContentTitle("1 new message")

.setContentText("It's time to take the medicine.");

mBuilder.setTicker("It's time to take the medicine.");// 第一次提示消息的时候显示在通知栏上

// mBuilder.setNumber(12);

mBuilder.setLargeIcon(btm);

mBuilder.setAutoCancel(true);// 自己维护通知的消失

// 构建一个Intent

Intent resultIntent = new Intent(KitActivity.this, KitActivity.class);

// 封装一个Intent

PendingIntent resultPendingIntent = PendingIntent.getActivity(

KitActivity.this, 0, resultIntent,

PendingIntent.FLAG_UPDATE_CURRENT);

// 设置通知主题的意图

mBuilder.setContentIntent(resultPendingIntent);

// 获取通知管理器对象

NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);

mNotificationManager.notify(0, mBuilder.build());

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI