如何为Android同步状态图标设置动画?

前端之家收集整理的这篇文章主要介绍了如何为Android同步状态图标设置动画?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我只是想启动和停止状态栏中的同步图标.我认为这将是一个使用NotificationManager的简单调用,但我无法在Web或SO上找到文档或示例Q& A.

解决方法

我找到了答案……

http://libs-for-android.googlecode.com/svn-history/r46/trunk/src/com/google/android/accounts/AbstractSyncService.java

显示了如何设置和取消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);
}
原文链接:https://www.f2er.com/android/316919.html

猜你在找的Android相关文章