Android:通知随记1
来源:互联网 发布:cvr100身份证阅读软件 编辑:程序博客网 时间:2024/05/17 00:52
1)通知的分类
普通通知,大视图通知,进度通知,自定通知
2)获取通知管理者
NotificationManager notificationMananger = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);3)创建通知公共的一些参数:公共的一些参数:// 创建视图Builder对象NotificationCompat.Builder builder = null;builder = new NotificationCompat.Builder(this);// 创建通知Builder对象 // 通知的图片builder.setSmallIcon(R.drawable.qq); // 设置自动消失builder.setAutoCancel(true); // 获取声音的UriUri sound = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://" + getPackageName() + "/" + R.raw.eatthings1); // 默认的声音// builder.setDefaults(Notification.DEFAULT_VIBRATE | // Notification.DEFAULT_SOUND); // 设置自定义通知的声音builder.setSound(sound);builder.setDefaults(Notification.DEFAULT_VIBRATE); // 获取PendingIntentIntent intent = new Intent(this, Activity00.class);PendingIntent pIntent = PendingIntent.getActivity(this, 0, intent, PendingIntent.FLAG_ONE_SHOT); // 设置未来的意图builder.setContentIntent(pIntent);Notification notification = null;4)普通通知
// 普通通知// 设置标题builder.setContentTitle("花千骨");// 设置内容builder.setContentText("我神的名义诅咒你(白子画):生生世世,不伤,不老,不死");notification = builder.build();notificationMananger.notify(0, notification);5)大视图通知
NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle( builder);style.setBigContentTitle("大视图通知");// 设置标题for (int i = 0; i < datas.length; i++) { style.addLine(datas[i]);// 一行一行加到箱子 } // 创建通知对象notification = builder.build(); // 短信管理者调用通知对象,进行通知notificationMananger.notify(1, notification);6)进度条通知
builder.setProgress(100, values[0], false);7)自定通知// 创建远程的View// packageName:包名RemoteViews remoteViews = new RemoteViews(getPackageName(), R.layout.view_notification_remote); // 修改远程ViewremoteViews.setTextViewText(R.id.remote_tv, "中秋节快乐");remoteViews .setImageViewResource(R.id.remote_image, R.drawable.sina);builder.setContent(remoteViews);notification = builder.build();notificationMananger.notify(3, notification);8)取消通知notificationMananger.cancelAll();cancel(id);
0 0
- Android:通知随记1
- android 随记
- android 随记
- Android随记
- android随记
- Android 随记
- Android随记
- android 随记
- Android随记(1):JAVA SDK安装
- Android开发随记(1)-- eclipse设置
- android 随记1 Dialog和输入法
- Android 学习随记笔记(1)
- 随记1
- 随记1
- JAVA&Android随记
- Android知识点随记
- Android随记(6)
- Android Training 学习随记
- 给自己的职场目标设定一个期限
- MMD 编程练习之 LSH
- Java反射
- 逆向破解_iOS_学习笔记_1
- Struts2中的值栈和OGNL
- Android:通知随记1
- 白手起家学习数据科学 ——k-Nearest Neighbors之“例子篇”(九)
- 51nod 1451:合法三角形 枚举斜率
- iOS开发之4种存储方式
- ARM_s5pv210_porting_2
- A+B for Input-Output Practice (VIII)(没啥用,来凑数)
- 4-5 求自定类型元素的最大值
- mysql 批量insert
- AnimTextView