首页 > 其他 > 详细

显示通知栏

时间:2014-03-10 01:00:22      阅读:424      评论:0      收藏:0      [点我收藏+]
	//显示通知栏图标
	private void showNotification() { 
        NotificationManager notificationManager = (NotificationManager) 
            this.getSystemService(android.content.Context.NOTIFICATION_SERVICE); 
        // 定义Notification的各种属性 
        Notification notification =new Notification(R.drawable.logo, 
                "YQ 正在运行", System.currentTimeMillis()); 
        notification.flags |= Notification.FLAG_ONGOING_EVENT; //加入通知栏的"Ongoing"中 
        notification.flags |= Notification.FLAG_NO_CLEAR; //点击了通知栏中的"清除通知"后不清除
        notification.flags |= Notification.FLAG_SHOW_LIGHTS; 
        notification.defaults = Notification.DEFAULT_LIGHTS; 
        // 设置通知的事件消息
        Intent notificationIntent =new Intent(this, MainActivity.class);  
        PendingIntent contentItent = PendingIntent.getActivity(this, 0, 
                notificationIntent, 0); 
        notification.setLatestEventInfo(this, 
        		"YQ",  // 通知栏标题
        		"Android 即时通信工具 YQ",  // 通知栏内容
        		contentItent); // 点击该通知后要跳转的Activity
        // 把Notification传递给NotificationManager,id为0
        notificationManager.notify(0, notification); 
    }


显示通知栏,布布扣,bubuko.com

显示通知栏

原文:http://blog.csdn.net/fangchao3652/article/details/20866913

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!