在状态栏中添加应用程序图标并打开

public static void showNotification() { NotificationManager nm = (NotificationManager) DownLoadActivity.mContext .getSystemService(NOTIFICATION_SERVICE); Notification notification = new Notification(R.drawable.lx_download, "xxxx", System.currentTimeMillis()); Intent intent = new Intent(mapIndex.curr, DownLoadActivity.class); PendingIntent pendIntent = PendingIntent.getActivity( DownLoadActivity.mContext, 0, intent, 0); notification.setLatestEventInfo(DownLoadActivity.mContext, "xxxx", "xxx", pendIntent); nm.notify(0, notification); } 移除图标: public static void doExit() { try { NotificationManager nm = (NotificationManager)DownLoadActivity.mContext.getSystemService(NOTIFICATION_SERVICE); nm.cancel(0); } catch (NullPointerException e) { // TODO Auto-generated catch block e.printStackTrace(); }
posted @ 2012-08-27 18:41  Dive  阅读(322)  评论(0编辑  收藏  举报