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

关于在通报显示通知

2012-09-14 
关于在通知显示通知?@Overridepublic void onCreate(Bundle savedInstanceState) {super.onCreate(savedIn

关于在通知显示通知

?

@Override    public void onCreate(Bundle savedInstanceState) {        super.onCreate(savedInstanceState);        setContentView(R.layout.main);

?

?NotificationManager notificationMgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

?

?

Notification notification = new Notificatio(drawable,tickerText,System.currentTimeMillis()); //此处定义了一个Notification ,其中第一个参数代表图标

第二个参数代表提示的内容,第三个参数是指要显示的时间,一般是当即显示,故填入系统当前时间。

?

?

PendingIntent contentIntent = PendingIntent.getActivity(this, 0, new Intent(this, ActivityMain.class), 0);

//该语句的作用是定义了一个不是当即显示的activity,只有当用户拉下notify显示列表,并且单击对应的项的时候,才会触发系统跳转到该activity.

??

notification.setLatestEventInfo(this, title, content, contentIntent);

?

//在此处设置在nority列表里显示的标题和样式。

?

//此处的NOTIFICATIONS_ID是为此通知指定一个id它是全局唯一的,方便以后引用

??

mNotificationManager.notify(NOTIFICATIONS_ID, notification);

?

?

?

?

?

?

热点排行