gpt4 book ai didi

android - 如何为 Android 同步状态图标制作动画?

转载 作者:塔克拉玛干 更新时间:2023-11-02 19:15:12 25 4
gpt4 key购买 nike

我只想启动和停止状态栏中的同步图标。我认为这将是一个使用 NotificationManager 的简单调用,但我无法在 Web 或 SO 上找到文档或示例问答。

最佳答案

我找到了我的答案......

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);
}

关于android - 如何为 Android 同步状态图标制作动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5061760/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com