android开发通知常用设置方法
来源:互联网 发布:淘宝客服兼职 靠谱吗 编辑:程序博客网 时间:2024/06/07 20:18
简单记录 通知上的设置方法,没有示例
//进度 通知 notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); builder = new NotificationCompat.Builder(context); builder.setContentTitle("新版本")//显示的标题 .setContentText("正在下载...")//显示的详细内容 .setSmallIcon(R.mipmap.ic_launcher); //提示文字 builder.setTicker("您有新消息!"); //点击取消,优先级 builder.setAutoCancel(true). setPriority(NotificationCompat.PRIORITY_DEFAULT); builder.setDefaults(Notification.DEFAULT_ALL); // 关联PendingIntent,点击跳转的页面 //PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, // new Intent(this, MainActivity.class), 0); //builder.setContentIntent(); //指定视图Notification 正常状态下的视图 // builder.build().contentView=contentView; //展开时的视图 //builder.build().bigContentView = expandView; /*提示方式 DEFAULT_ALL:铃声、闪光、震动均系统默认。 DEFAULT_SOUND:系统默认铃声。 DEFAULT_VIBRATE:系统默认震动。 DEFAULT_LIGHTS:系统默认闪光。 其他方式: setSound(Uri sound):设定一个铃声,用于在通知的时候响应。 传递一个Uri的参数,格式为“file:///mnt/sdcard/Xxx.mp3”。 setLights(int argb, int onMs, int offMs):设定前置LED灯的闪烁速率, 持续毫秒数,停顿毫秒数。 setVibrate(long[] pattern):设定震动的模式,以一个long数组保存毫秒级间隔的震动。 */ /* setStyle()传递一个NotificationCompat.Style对象,它是一个抽象类, Android为我们提供了三个实现类,用于显示不同的场景。分别是: NotificationCompat.BigPictureStyle, 在细节部分显示一个256dp高度的位图。 NotificationCompat.BigTextStyle,在细节部分显示一个大的文本块。 NotificationCompat.InboxStyle,在细节部分显示一段行文本。*/ //builder.setWhen();//设置通知的时间,默认当前时间
发送通知:
//更新进度 builder.setProgress((int) l, (int) l1, true); //发送通知 notificationManager.notify(notificationFlag, builder.build());取消通知:
notificationManager.cancel(notificationFlag);
0 0
- android开发通知常用设置方法
- android开发常用方法
- Android开发常用方法
- Android Studio常用设置方法
- android常用通知管理、自定义通知图标的两种方法
- android开发(32) android 中 actionbar 常用方法。设置标题,隐藏图标等
- android开发 - 状态栏通知
- Android开发之通知
- Android开发设置一些常用属性
- Android 通知栏NotificationManager设置
- android设置通知栏颜色
- Android 设置透明通知栏
- android 设置闹钟及通知
- android通知栏通知的开发笔记
- iOS开发之换肤皮肤设置详细实现_通知方法
- Android JNI开发中的常用方法
- Android开发当中常用的方法集锦
- Android开发当中常用的方法集锦
- Oracle11g使用exp导出空表
- 常用的正则表达式总结
- Java的类加载步骤
- 奇数阶魔方
- java适配器模式
- android开发通知常用设置方法
- Andorid总结 - Bound Services
- 【模板】快速幂
- 二叉树的深度优先与广度优先算法
- Java 从HTML中取得想要的信息再进行处理
- 怎样将Activity设置成窗口模式
- 查询数据库时间显示 时 分 秒
- mybatis-generator使用之MyBatis Generator配置文件翻译
- android 城市列表