Notification and Toast comments
2015-10-30 17:13
351 查看
1。 Notification. 对用户进行状态的提示和允许用户进行动作的选择。
Notification area & Notification Draw
API20 支持 heads-up notification
API21 支持Lock Screen Notification
有以下显示形式
1。最简单的icon,title和content text
2。系统定义的style
3。可以有用户定义view
5。可以放置action
1。创建
2。发送
3。取消
可以按系统类别归类
可以设置优先级
可以设用户(另一中归类的方法)
在发送时给一个id,随后可以用此ID更新。Notification是一个存储在系统的token,类是pendingitent
Toast
可以设置用户自定义view
可以自定义位置
Notification area & Notification Draw
API20 支持 heads-up notification
API21 支持Lock Screen Notification
有以下显示形式
1。最简单的icon,title和content text
2。系统定义的style
NotificationCompat.Builder | setStyle(NotificationCompat.Style style) |
public NotificationCompat.BuildersetContent(RemoteViews views)
4。可以放置进度条... mNotifyManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); mBuilder = new NotificationCompat.Builder(this); mBuilder.setContentTitle("Picture Download") .setContentText("Download in progress") .setSmallIcon(R.drawable.ic_notification); // Start a lengthy operation in a background thread new Thread( new Runnable() { @Override public void run() { int incr; // Do the "lengthy" operation 20 times for (incr = 0; incr <= 100; incr+=5) { // Sets the progress indicator to a max value, the // current completion percentage, and "determinate" // state mBuilder.setProgress(100, incr, false); // Displays the progress bar for the first time. mNotifyManager.notify(0, mBuilder.build()); // Sleeps the thread, simulating an operation // that takes time try { // Sleep for 5 seconds Thread.sleep(5*1000); } catch (InterruptedException e) { Log.d(TAG, "sleep failure"); } } // When the loop is finished, updates the notification mBuilder.setContentText("Download complete") // Removes the progress bar .setProgress(0,0,false); mNotifyManager.notify(ID, mBuilder.build()); } } // Starts the thread by calling the run() method in its Runnable ).start();
5。可以放置action
NotificationCompat.Builder | addAction(int icon,CharSequence title,PendingIntent intent) |
NotificationCompat.Builder
2。发送
mNotificationManager.notify
3。取消
mNotificationManager.cancel 取消, 也可以设置点击取消
可以按系统类别归类
可以设置优先级
可以设用户(另一中归类的方法)
在发送时给一个id,随后可以用此ID更新。Notification是一个存储在系统的token,类是pendingitent
Toast
可以设置用户自定义view
可以自定义位置
相关文章推荐
- 充分统计量
- Asp.Net MVC 4 Web API 中的安全认证-使用OAuth
- RHEL 7.1配置Kubernetes集群环境
- VARCHAR2(N CHAR)与VARCHAR2(N)的区别[Oracle基础]
- 负载均衡学习笔记
- java对象转型
- com.alibaba.fastjson.JSONObject.getString耗时问题
- 安卓开发必须收藏的网站
- [初级]设计模式--装饰模式
- Multipart/form-data POST文件上传详解
- 常用链接
- CodeForces 253D Table with Letters - 2
- 源代码解析Servlet生命周期 转自segmentfault
- HDU 4337 暴力
- ui中各种手势的用法
- CGContextRef详解
- Unity3D技术之分析器 (Profiler) 窗口详解
- 1059. Prime Factors
- 与多线程结合使用的消息处理类Handler、Message
- 短信中VB.NET编码PDU(一)