Android推送通知

 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());

你可能感兴趣的:(android,message,medicine)