android通知栏Notification
16lz
2022-04-08
Notification是通过NotificationManager来处理的,功能包括:
·设置通知栏图标;
·设置通知栏标题;
·设置通知栏内容;
·设置点击通知栏activity的跳转;
·设置闪灯/LED;(收到短信或来电话时)
·设置铃声、震动等;
noti哪来,请看:
注:pendingIntent是个PendingIntent,看名字就知道,延迟的activity,指定义某一时间出现的Intent,当然你也可以设置为null。
我的博客其它文章列表
http://my.oschina.net/helu
·设置通知栏图标;
·设置通知栏标题;
·设置通知栏内容;
·设置点击通知栏activity的跳转;
·设置闪灯/LED;(收到短信或来电话时)
·设置铃声、震动等;
NotificationManager notiManage = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); notiManage.notify(1, noti);
noti哪来,请看:
Notification noti = new Notification(); noti.icon = R.drawable.ic_launcher; noti.tickerText = "This is test!"; noti.when = System.currentTimeMillis(); //这里是显示时:分,如22:43 noti.setLatestEventInfo(this, noti.tickerText, "AAA", pendingIntent); //将以上东西setView到Notification上去,要不然显示什么呀
注:pendingIntent是个PendingIntent,看名字就知道,延迟的activity,指定义某一时间出现的Intent,当然你也可以设置为null。
Intent intent = new Intent(this, MainActivity.class); PendingIntent pendingIntent = PendingIntent.getActivity(this, 0,intent, 0);
我的博客其它文章列表
http://my.oschina.net/helu
更多相关文章
- 实用代码3
- Android下PreferenceScreen 加载流程
- android editText 软键盘enter键图标的设置
- Android(安卓)使用ActivityOptions实现Activity转场动画
- 【Android】android:padding属性设置对ImageButton无效问题
- android 背景图片设置
- Android(安卓)软键盘问题总结
- android中menu的使用
- Android(安卓)Animation开机动画的优化