您的位置:首页 > 移动开发 > Android开发

android显示一个通知

2015-09-29 10:10 417 查看
简单的显示一个通知栏提醒

Notification notification = new Notification(icon, tickerText, when);
//点击可以取消通知
notification.flags=Notification.FLAG_AUTO_CANCEL;
//通知时亮屏,震动,提示音
notification.defaults = Notification.DEFAULT_ALL;
//通知等设置
notification.ledARGB=0x00ff00;
notification.ledOffMS=100;
notification.ledOnMS=100;

//定义下拉通知栏时要展现的内容信息

CharSequence contentTitle = "效率大师打卡提醒";

CharSequence contentText = "亲~不要忘了打卡呦~";

Intent notificationIntent = new Intent(context, MainActivity.class);

PendingIntent contentIntent = PendingIntent.getActivity(context, 0,notificationIntent, 0);

notification.setLatestEventInfo(context, contentTitle, contentText,contentIntent);

mNotificationManager.notify(1, notification);
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: