android 信手记 广播通知栏 二

android 随手记 广播通知栏 二关于通知栏的使用:Notification及NotificationManager的使用详解相关类:impo

android 随手记 广播通知栏 二

关于通知栏的使用:

Notification及NotificationManager的使用详解  


相关类:

import android.app.NotificationManager;
import android.app.PendingIntent;

import android.app.Notification;

1、使用标准的布局来显示通知信息

  • Intent intent = new Intent(MainActivity.this,Other.class);                  //intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);                                  
  •                 PendingIntent pi = PendingIntent.getBroadcast(MainActivity.this, 0, intent, 0);                                 
  •                 Notification notification = new Notification(R.drawable.ic_action_search,"fadf",SystemClock.currentThreadTimeMillis());                   //这一种里面的构造方法,可以理解为使用默认的布局进行现实的,显示图标,滚动图标的显示内容,以及显示时间。  
  •                  notification.setLatestEventInfo(MainActivity.this,"你好", "还不错", pi); //在通知栏中现实的内容           
  •                 NotificationManager  ni = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);                  ni.notify(NOTIFICATION_ID, notification);