Skip to content

Instantly share code, notes, and snippets.

@Aiur3908
Created April 30, 2015 08:14
Show Gist options
  • Save Aiur3908/08e267a219059fc6fcae to your computer and use it in GitHub Desktop.
Save Aiur3908/08e267a219059fc6fcae to your computer and use it in GitHub Desktop.
private void sendNotification() {
int notificationId = 001;
//決定這個notification的辨識編號
Bitmap bitmap = BitmapFactory.decodeResource(getResources() , R.drawable.a1);
//取得要發送的圖片
NotificationCompat.BigPictureStyle bigPictureStyle = new NotificationCompat.BigPictureStyle();
bigPictureStyle.bigPicture(bitmap);
//創建一個BigPictureStyle物件,並設定要傳送的圖片
NotificationCompat.Builder notifcaition =
new NotificationCompat.Builder(this)
.setSmallIcon(R.drawable.ic_launcher)
.setContentTitle("標題")
.setContentText("我是小狗")
.setStyle(bigPictureStyle);
//最後在setStyle,將剛才的創建一個BigPictureStyle物件物件丟入即可
NotificationManagerCompat notificationManagerCompat = NotificationManagerCompat.from(this);
//取得NotificationManagerCompat的實體
notificationManagerCompat.notify(notificationId , notifcaition.build());
//填入辨識編號及notification後,即可發送出去
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment