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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。