新(New):Notification.Builder來快速產生出來
NotificationManager notificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE ); Builder builder = new Notification.Builder(Update.this ); PendingIntent contentIndent = PendingIntent.getActivity(Update. this, 0, new Intent(Update.this , Update. class),PendingIntent. FLAG_UPDATE_CURRENT); builder.setContentIntent(contentIndent) .setSmallIcon(R.drawable.icon) // 設置狀態列裡面的圖示 .setTicker("New Message") // 設置狀態列的顯示的資訊 .setWhen(System. currentTimeMillis()) // 設置發生時間 .setContentTitle( "I-Calories計算結果通知" )//設置通知清單裡的標題 .setContentText("共消耗"+ca); // 設置內容 Notification notification = builder.getNotification(); notificationManager.notify(1, notification);設定預設提示音(notification.defaults to set default alarm ring)
notification.defaults |= Notification.DEFAULT_SOUND;//預設鈴聲相關連結(good learning website) 更詳細可以點及這個很棒的網站作更深入的學習 http://magiclen.org/android-notifications/
http://www.codedata.com.tw/mobile/android-tutorial-the-5th-class-2-notificationhttp://givemepass.blogspot.tw/2011/11/notification.html
http://blog.maxkit.com.tw/2014/03/android-notification.html
沒有留言:
張貼留言