android 添加 notification
来源:互联网 发布:淘宝qq推广 编辑:程序博客网 时间:2024/05/15 21:48
1.定义notification
private NotificationCompat.Builder mBuilder;mBuilder = new NotificationCompat.Builder(MainActivity.this).setSmallIcon(R.drawable.a).setContentTitle("").setContentText("");
2.添加点击notification跳转至activity
private Intent i_notifi;private PendingIntent pi;i_notifi = new Intent(this,MainActivity.class);pi = PendingIntent.getActivity(this, 0, i_notifi, PendingIntent.FLAG_UPDATE_CURRENT);mBuilder.setContentIntent(pi);
3.启动notification
private NotificationManager nm;nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);nm.notify(001, mBuilder.build());
PS:点击notification后自动取消通知栏
mBuilder.setAutoCancel(true);
4.设置notification 显示多文字
Notification notif = new Notification.Builder(mContext) .setContentTitle("New mail from " + sender.toString()) .setContentText(subject) .setSmallIcon(R.drawable.new_mail) .setLargeIcon(aBitmap) .setStyle(new Notification.BigTextStyle() .bigText(aVeryLongString)) .build();
参考
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
- Android Notification
- 【WebService】4.使用CXF处理JavaBean和List集合
- 非常有用专业网站
- 在jsp页面下, 让eclipse完全支持HTML/JS/CSS智能提示
- UICollectionView 的一些坑
- window.location相关内容
- android 添加 notification
- Android ListView滑动中图片显示重复错位问题
- OpenGL ES着色器语言之内建函数(官方文档第八章)
- 浅谈Service
- 数组中至多有一个出现次数大于数组长度一半元素,找出这个元素
- Android插件化:从入门到放弃
- js插件搜集
- 七牛-获取下载链接(java)
- spring注解