public class NotificationUtils {
public static void showStatusbarNotification(Context context, CharSequence text) {
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.icon, text, System.currentTimeMillis());
notification.ledARGB = Color.BLUE;
notification.ledOnMS = 100;
notification.ledOffMS = 100;
notification.defaults |= Notification.DEFAULT_LIGHTS;
notification.flags = notification.flags |
Notification.DEFAULT_LIGHTS |
Notification.FLAG_ONLY_ALERT_ONCE |
Notification.FLAG_SHOW_LIGHTS;
CharSequence contentTitle = context.getText(R.string.app_name);
CharSequence contentText = text;
Intent notificationIntent = new Intent(context, MyActivity.class);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
nm.notify(0, notification);
}
}
分享到:
相关推荐
notification在新版本的SDK上的写法 blog:http://www.cnblogs.com/ityizhainan/p/6282031.html
Notification
Notification最新用法、实现Notification的通知栏常驻、Notification的各种样式big View、解决Notification点击无效
疯狂Android中有关Notification的简单例子
使用javascript 封装实现 Notification 消息通知框
各种Notification的使用技巧
示例功能包含普通Notification、折叠式Notification和悬挂式Notification,并且实现了Notification的显示等级。
android notification 通知 demo
调用getSystemService(NOTIFICATION_SERVICE)方法获取系统的NotifacationManager服务 通过构造器创建一个Notification对象 为Notification设置各种属性 通过NotificationManager发送Notification。
Android NOtification 使用Android NOtification 使用
Bluetooth Alert Notification Profile
Notification的使用示例各种效果,包含系统一般notification的示例,以及自定义铃声震动等
iphone notification机制导读。理解notification的工作机理,不仅仅局限于简单使用。
android notification完全解析Demo
Notification显示音乐下载的界面
通过RemoteView制作自定义Notification
这个例子演示Android 在状态栏添加Notification信息图标及提示,相信大家对这个功能已经不陌生了,手机中安装的APP,一般都会在后台运行,时不时会在手机顶部的状态栏中显示应用的图标,滑出状态栏会看到详细的信息...