我只是想启动和停止状态栏中的同步图标.我认为这将是一个使用NotificationManager的简单调用,但我无法在Web或SO上找到文档或示例Q& A.
解决方法
我找到了答案……
这显示了如何设置和取消stat_notify_sync图标.
private void showNotification(String authority) { Object service = getSystemService(NOTIFICATION_SERVICE); NotificationManager notificationManager = (NotificationManager) service; int icon = android.R.drawable.stat_notify_sync; String tickerText = null; long when = 0; Notification notification = new Notification(icon,tickerText,when); Context context = this; CharSequence contentTitle = "mobi"; //createNotificationTitle(); CharSequence contentText = "bob"; //createNotificationText(); PendingIntent contentIntent = createNotificationIntent(); notification.when = System.currentTimeMillis(); notification.flags |= Notification.FLAG_ONGOING_EVENT; notification.setLatestEventInfo(context,contentTitle,contentText,contentIntent); notificationManager.notify(mNotificationId,notification); } private void cancelNotification() { Object service = getSystemService(NOTIFICATION_SERVICE); NotificationManager nm = (NotificationManager) service; nm.cancel(mNotificationId); }