[Toast]
1,显示提示信息
public static Toast makeText (Context context, CharSequence text, int duration).show()
public static Toast makeText (Context context, int resId, int duration).show()
duration可以是:Toast.LENGTH_LONG,Toast.LENGTH_SHORT
[Notification]
1,(NotificationManager)getSystemService(NOTIFICATION_SERVICE) 获取NotificationManager 通知管理器
2,实例化Notification
设置属性
icon 图标
tickerText 通知栏显示的内容
defaults 震动(Notification.DEFAULT_VIBRATE) /声音(Notification.DEFAULT_SOUND) /光照(Notification.DEFAULT_LIGHTS) /Notification.DEFAULT_ALL
3,通知被查看设置
setLatestEventInfo(Context context, CharSequence contentTitle, CharSequence contentText, PendingIntent contentIntent)
contentIntent=PendingIntent.getActivity(this, 0, new Intent(this, 该通知被点击时调用Activity.class), 0)
4,显示
NotificationManager.notify(int id, Notification notification)显示通知
5,取消显示
NotificationManager.cancel(int id)//id=notify中的id且大于0
NotificationManager.cancelAll()取消全部通知
6,其他
振动加权限<uses-permission android:name="android.permission.VIBRATE"></uses-permission>