Android 通知欄Notification 懸浮通知欄
阿新 • • 發佈:2018-12-28
NotificationManager mNotificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); Notification.Builder builder = new Notification.Builder(this); Intent intent = new Intent(Main2Activity.this,ReceiveMailActivity.class); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0); builder.setContentIntent(pendingIntent); builder.setSmallIcon(R.drawable.logo); builder.setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.logo)); builder.setAutoCancel(true); builder.setContentTitle("懸掛式通知"); builder.setFullScreenIntent(pendingIntent, true); mNotificationManager.notify(2, builder.build());
親測可用