android notification and notificationmanager
来源:互联网 发布:中外标准数据库 编辑:程序博客网 时间:2024/06/06 01:34
一:Notification 和NotificationManager,不多说,贴代码。通知栏的
public void creatSystemNotif(int type,Context context){
//type=0表示系统所给界面类型,type=1表示自定义界面类型
//FLAG_NO_CLEAR 该通知能被状态栏的清除按钮给清除掉
//FLAG_ONGOING_EVENT 通知放置在正在运行
//FLAG_INSISTENT 通知的音乐效果一直播放
//FLAG_AUTO_CANCEL; 自动取消通知栏
//FLAG_FOREGROUND_SERVICE 前景服务
//ONLY_ALERT_ONCE 警告一次
Intent intent=new Intent(this,SecondActivity.class);
PendingIntent pi=PendingIntent.getActivity(context, 1, intent, PendingIntent.FLAG_UPDATE_CURRENT);
switch(type){
//系统
case 0:
Notification nf0=new Notification(R.drawable.icon, "系统通知栏",1000);
nf0.setLatestEventInfo(context, "title", "当前的通知栏", pi);
//PS:以上的效果常量可以累加,即通过mNotifaction.defaults |=DEFAULT_SOUND (有些效果只能在真机上才有,比如震动)
//flags 变化属性
nf0.flags =Notification.FLAG_INSISTENT;
nf0.flags |=Notification.FLAG_NO_CLEAR;
//defaults效果
nf0.defaults =Notification.DEFAULT_VIBRATE;
nf0.ledARGB = 0xff00ff00;
nf0.ledOnMS = 500;
nf0.ledOffMS = 2000;
NotificationManager nfm=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
nfm.notify(1, nf0);
break;
//自定义
case 1:
Notification nf1=new Notification(R.drawable.icon, "自定义Notification",System.currentTimeMillis());
RemoteViews contentView=new RemoteViews(getPackageName(),R.layout.notification);
contentView.setTextViewText(R.id.textview1, "Push广告");
contentView.setTextViewText(R.id.textview2,"通知栏广告");
nf1.contentView=contentView;
nf1.contentIntent=pi;
NotificationManager nfm1=(NotificationManager)getSystemService(Context.NOTIFICATION_SERVICE);
nfm1.notify("自定义Notification", 1, nf1);
break;
}
}
- android notification and notificationmanager
- android notification,notificationmanager详解
- NotificationManager and Notification学习笔记
- ndroid -- NotificationManager and Notification学习笔记
- Notification ,NotificationManager
- NotificationManager 、 Notification
- Notification、NotificationManager
- Android状态栏提醒(Notification,NotificationManager)的使用!
- android----NotificationManager和Notification的使用总结
- 【Android】状态栏通知Notification、NotificationManager详解
- Android-----状态烂提示(Notification、NotificationManager)
- Android NotificationManager 和Notification的使用总结
- Android NotificationManager 和Notification的使用总结
- Android NotificationManager 和Notification的使用总结
- Android NotificationManager 和Notification的使用总结
- 【Android】状态栏通知Notification、NotificationManager详解
- Android NotificationManager 和Notification的使用总结
- 【Android】状态栏通知Notification、NotificationManager详解
- 几个 JS 函数分享
- 反射字段属性
- android蓝牙文件传输的实现
- 自定义数字格式字符串
- Qt Designer工具与uic的使用
- android notification and notificationmanager
- python2.7 使用super关键词 报错 TypeError: must be type, not classobj 解决办法
- HTTP头信息
- 10 个实用的 jQuery 表单操作代码片段
- unity3d的优化
- OnPaint
- 飞音网络电话V2.0.3.0 [语质卓越 绿色小巧]
- 利用多个模版来构建同源模型
- 一张图片