Android中通知栏的使用方法
来源:互联网 发布:windows powershell 编辑:程序博客网 时间:2024/05/01 03:56
3.0以上系统中Notification 的setLatestEventInfo已经不推荐使用了,所以用Notification.Builder改造了一下:
显示通知栏
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
public void setNotification() {
PendingIntent contentIntent = PendingIntent.getActivity(this, 0,
new Intent("com.android.XXX.XXX")
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK), 0);
Builder builder = new Notification.Builder(this);
builder.setContentIntent(contentIntent)
.setSmallIcon(R.drawable.XXX)
.setWhen(System.currentTimeMillis()).setAutoCancel(false)
.setContentTitle(statusContentTitle).setContentText(statusContentContext);
startForeground(XXX, builder.getNotification());
nm.notify(1, notification);
}
隐藏通知栏
public void closeNotification() {
if (nm != null) {
nm.cancel(1);
}
}
- Android中通知栏的使用方法
- Swift中通知的使用方法(Swift3)
- android中通知栏notification的使用
- Android中通知栏的使用
- Android中通知栏的使用
- android studio中创建使用菜单和Toast通知的使用方法
- 通知的基本使用方法
- 通知的使用方法
- android中通知的使用
- Android中通知的使用
- Android中简单的通知
- IOS中Notificaiton通知的使用方法<代码演示>
- android通知栏通知的开发笔记
- android通知栏的消息通知(Notification)
- Android framework中去除通知栏中通知的应用图标
- Android通知栏通知
- Android中屏蔽有新短信时通知栏里的通知
- Android中通知的简单使用和自定义通知样式
- poj 2408 字符串模拟题(值得回顾)。
- memcach类库
- The Linux Serial Programming
- poj1782 字符串模拟题(统计相邻单词个数)
- 《程序员,你伤不起》读书笔记 (一)
- Android中通知栏的使用方法
- 数据管理_三探MDB数据库
- poj3461 KMP
- WP系统一次订阅,终身锁屏同时显示农历和天气
- 从零开始学compiler--3--3--Regular Language
- 《从程序员到项目经理》读书笔记(一)
- Windows下安装MySQL解压版
- STM32_APIO 复用(转)
- Merge Sorted Array