Android中Notification的使用
来源:互联网 发布:手机淘宝联盟自己购买 编辑:程序博客网 时间:2024/05/01 11:55
Notification在通知栏发送通知以进行消息提醒
private int NOTIFICATION_ID = 0;//设置Notification的ID以便后续更新消息内容 Intent intent = new Intent(getApplicationContext(), MainActivity.class);//设置一个Intent进行点击后的操作 PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, intent, 0);//设置点击后跳转到Intent Builder builder = new Builder(MainActivity.this);//此处需要引用android.support.v7.app.NotificationCompat.Builder builder.setSmallIcon(R.drawable.ic_luancher);//设置Notification图标 builder.setContentTitle("新消息!");//设置Notification的标题 builder.setContentText("您有新消息!");//设置Notification的内容 builder.setSubText("消息的详细内容!");//设置Notification的扩展信息 builder.setAutoCancel(true);//设置Notification可以清除 builder.setContentIntent(pendingIntent);//设置点击后跳转到Intent Notification notification = builder.build();//创建并获取Notification的真实对象 NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);//获取服务 notificationManager.notify(NOTIFICATION_ID,notification);//ID用于后续更新Notification内容
0 0
- Android中Notification的使用
- Android中Notification的使用
- Android中Notification的使用
- Android中使用Notification
- Android中通知的使用-----Notification详解
- Android中通知的使用-----Notification详解
- Android中通知的使用-----Notification详解
- Android中Notification的使用以及自定义
- Android中通知的使用-----Notification详解
- android中通知栏notification的使用
- Android开发中Notification的使用
- Android中通知的使用-----Notification详解
- Android中通知的使用-----Notification详解
- Android中通知的使用-----Notification详解
- Android中通知的使用-----Notification详解
- Android中通知的使用-----Notification详解
- Android 中Notification和NotificationManager的使用
- Notification,Android中通知的使用
- Python学习笔记(一)
- SharedPreference 工具类
- CSS3弹性布局align-items和align-self垂直轴方向行对齐属性详解及实例
- C++工作现在需求怎么样,如何应对
- 快速幂
- Android中Notification的使用
- PAT-A1061 Dating (20)(模拟)
- 统计你的手机号码中出现次数最多的数字,并打印出此数字及其出现次数
- 【小笔记】设置圆角、边框
- Android自定义控件
- uva 11461 数学
- POJ2516 Minimum Cost(K次费用流)
- 效率: 条款23 考虑使用其他程序库
- 包管理工具Chocolatey使用方法