1. 程式人生 > >android 桌面通知notify

android 桌面通知notify

https uil tco send uri scree www. .com intent

private void sendNotify() {
NotificationManager manager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
NotificationCompat.Builder builder = new NotificationCompat.Builder(MainActivity.this,"default");
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.baidu.com")); // 此處根據需要改為打開應用


PendingIntent pi = PendingIntent.getActivity(MainActivity.this, 0, intent, 0);
Notification notify = builder.setSmallIcon(R.mipmap.ic_launcher_round)
.setPriority(Notification.PRIORITY_DEFAULT) //通知的優先級
.setCategory(Notification.CATEGORY_MESSAGE) //通知的類型
.setContentTitle("Order Notify")
.setAutoCancel(true)
.setContentIntent(pi)
.setContentText("a new order message")
.setFullScreenIntent(pi, true) //不設置此項不會懸掛,false 不會出現懸掛
.build();
manager.notify(1,notify);
}

android 桌面通知notify