26通知使用

来源:互联网 发布:淘宝付款打不开怎么办 编辑:程序博客网 时间:2024/05/22 17:26


1、Notification通知

private void showNotification() {
  NotificationManager manager = (NotificationManager) this
    .getSystemService(NOTIFICATION_SERVICE);
  Notification notification = new Notification(R.drawable.ic_launcher,
    "我爱你", System.currentTimeMillis());
  PendingIntent intent = PendingIntent.getActivity(this, 0, new Intent(
    this, DialogTestActivity.class), 0);
  notification.setLatestEventInfo(this, "我说的", "你爱我", intent);
  
  //notification.defaults = Notification.DEFAULT_ALL;//震动加声音
  manager.notify(520, notification);
  //manager.cancel(520);//清除通知
 }

0 0
原创粉丝点击