Notificaiton状态通知栏

来源:互联网 发布:vbscript linux 编辑:程序博客网 时间:2024/05/16 14:30
功能作用

1.显示接收到短消息、即使消息等信息 (如QQ、微信、新浪、短信)

2.显示客户端的推送消息(如有新版本发布,广告,推荐新闻等) 

3.显示正在进行的事物(例如:后台运行的程序)(如音乐播放器、版本更新时候的下载进度等)

private static int MSG_NOTIFICTION_ID = 2;/发通知private void notifyUserWithNewMessage(Context context,Intent intentActivity,String title,String ticker,String message) {    NotificationManager notiManager = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);    Notification notification = new Notification(MSG_NOTIFICTION_ID,ticker, System.currentTimeMillis());    //do    intentActivity.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP| Intent.FLAG_ACTIVITY_NEW_TASK);    PendingIntent pendingIntent = PendingIntent.getActivity(            getApplicationContext(), 100, intentActivity,            PendingIntent.FLAG_UPDATE_CURRENT);    notification.setLatestEventInfo(getApplicationContext(),title,            message, pendingIntent);    Uri curNotifyUri = RingtoneManager.getActualDefaultRingtoneUri(context, 2);    notification.sound = curNotifyUri;    notiManager.notify(0, notification);}//取消通知private void notifyCancel(Context context) {    NotificationManager notiManager = (NotificationManager) context.getSystemService(NOTIFICATION_SERVICE);       notiManager.cancel(MSG_NOTIFICTION_ID);}


http://blog.csdn.net/vipzjyno1/article/details/25248021/

0 0
原创粉丝点击