android中Notification的用法
来源:互联网 发布:拓词软件下载 编辑:程序博客网 时间:2024/06/09 20:02
总结4步
1 获取通知对象
2新建建Notification
3关联意图
4执行通知
案例如下
<span style="font-size:18px;"></span>
<span style="font-size:18px;">private void button1() {count++;NotificationManager manager = (NotificationManager) MainActivity.this.getSystemService(Context.NOTIFICATION_SERVICE);Notification notification = new Notification(R.drawable.ic_launcher,"我是通知", System.currentTimeMillis());notification.flags = Notification.FLAG_AUTO_CANCEL;notification.number = count;Intent it = new Intent(Intent.ACTION_CALL, Uri.parse("tel:110"));it.putExtra("name", "name" + count);PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 12, it,PendingIntent.FLAG_CANCEL_CURRENT);notification.setLatestEventInfo(this, "标题", "启动多条显示一条", pendingIntent);manager.notify(100, notification);}</span>执行多条但是只显示一次,点击只执行一次,只显示一次与manager.notify(n, notification);中的n有关,n是固定的只显示一次,
只执行一次与PendingIntent pendingIntent = PendingIntent.getActivity(getApplicationContext(), 12, it,PendingIntent.FLAG_CANCEL_CURRENT);中的数字有关,相同只执行一次,不相同,可执行多次
其他的boutton事件,只要根据以上规律就可以做出,
自定义格式,除了一其他的自定义style一样,还有必须加载
RemoteViews contentView = new RemoteViews(getPackageName(), R.layout.自定义的style);
notification.contentView = contentView;
就可以了
0 0
- Android中Notification的用法
- android中Notification的用法
- android中关于notification的最新用法
- Android中Notification通知的用法
- android notification 的用法
- android notification的用法
- android中notification的用法(简单易懂用法)
- Android的Notification的用法
- android app notification的用法
- Android Notification的多种用法
- Android Notification的多种用法
- Android中Notification的使用
- Android中Notification的使用
- Android 中Notification的运用
- Android中Notification的使用
- Android之Notification的多种用法
- Android Notification的作用和用法
- Android Notification的用法及步骤
- Ubuntu14.04下单机版Spark的部署
- 解决ubuntu上ifconfig没有eth0且无法上网的问题
- 技术博客启用记录
- 喷水装置 ACM题目 京东16招聘编程题(贪心算法)
- C++11 Object初始化问题
- android中Notification的用法
- 进制转化(尤其是负进制)
- UIScrollView的重用机制的理解
- Java中整型的缓存机制
- linux(centos)搭建svn服务器
- iOS点击屏幕使tableview、scrollview回到顶部
- win10下matplotlib中文乱码解决方案
- Miscrosoft Visual Studio 2010 使用技巧总结
- 五.检查和比较