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

Notification 的应用

2012-09-27 
Notification 的使用NotificationManager mNM (NotificationManager)getSystemService(NOTIFICATION_SER

Notification 的使用

NotificationManager mNM = (NotificationManager)getSystemService(NOTIFICATION_SERVICE);// Set the icon, scrolling text and timestamp  设置可以在状态栏上显示的图标和提示信息      Notification notification = new Notification(R.drawable.stat_sample, text,                    System.currentTimeMillis());// The PendingIntent to launch our activity if the user selects this notification//用户在状态栏点击相应的notify可以发送的Intent(连接到相应的activity)            PendingIntent contentIntent = PendingIntent.getActivity(this, 0,                    new Intent(this, ForegroundServiceController.class), 0);// Set the info for the views that show in the notification panel.//状态栏的notify展开后显示的文本信息            notification.setLatestEventInfo(this, getText(R.string.local_service_label),                           text, contentIntent);mNM.notify(R.string.foreground_service_started, notification);//使用R.string.foreground_service_started 是因为它是一个唯一ID//取消notifymNM.cancel(id);//id=R.string.foreground_service_started 之前定义的一个唯一ID



热点排行