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