首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

NotificationManager通报使用

2012-08-29 
NotificationManager通知使用有些时候需要做类似于电话,短信未读情况,显示在屏幕上方时。就要用到notificat

NotificationManager通知使用
有些时候需要做类似于电话,短信未读情况,显示在屏幕上方时。就要用到notificationManager通知。
下面有个列子:
 

NotificationManager manager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);Notification notification = new Notification(R.drawable.icon,"收到任务", System.currentTimeMillis());//通知内容RemoteViews remoteViews=new RemoteViews(getPackageName(), R.layout.notification);remoteViews.setImageViewResource(R.id.image, R.drawable.user);remoteViews.setTextViewText(R.id.text, "content");notification.contentView=remoteViews;//点击进入详细内容notification.contentIntent=PendingIntent.getActivity(LaunchNotificationActivity.this, 0,new Intent(LaunchNotificationActivity.this,ShowContent.class), 0);//设置铃音notification.flags|=Notification.FLAG_AUTO_CANCEL;notification.defaults |= Notification.DEFAULT_SOUND;manager.notify(1, notification);  

热点排行