android 桌面通知notify

花门楼前见秋草,岂能贫贱相看老。这篇文章主要讲述android 桌面通知notify相关的知识,希望能为你提供帮助。
【android 桌面通知notify】 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);
}
















    推荐阅读