5

我搜索了很多东西,例如: 如何在谷歌地图上显示闪烁的图标

但据此我不知道如何闪烁通知图标闪烁

我想在此闪烁图标

 int icon = R.drawable.ic_launcher;
long when = System.currentTimeMillis();
notificationManager = (NotificationManager) context
        .getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(icon, "Hi M rohit", when);
String title = context.getString(R.string.app_name);
Intent notificationIntent = new Intent(context, Home.class);
// set intent so it does not start a new activity
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, title, "Rohit", intent);
//notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.flags |= Notification.FLAG_SHOW_LIGHTS;
notification.flags |= Notification.FLAG_NO_CLEAR;
notification.defaults = Notification.DEFAULT_ALL;
notificationManager.notify(NOTIFICATION, notification);
4

2 回答 2

7

我找到了解决方案:我创建了动画文件并设置了该文件,谢谢我找到了解决方案

在此处设置文件名:-

   int icon = R.drawable.animationfile;
long when = System.currentTimeMillis();
notificationManager = (NotificationManager) context
        .getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(icon, "Your location is tracing", when);
String title = context.getString(R.string.app_name);
Intent notificationIntent = new Intent(context, Home.class);
// set intent so it does not start a new activity
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, title, "Rohit", intent);
//notification.flags |= Notification.FLAG_AUTO_CANCEL;
notification.flags |= Notification.FLAG_SHOW_LIGHTS;
notification.flags |= Notification.FLAG_NO_CLEAR;
notification.defaults = Notification.DEFAULT_ALL;
notificationManager.notify(NOTIFICATION, notification);

我创建了这个文件

动画文件.xml:

  <animation-list
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:oneshot="false">
<item android:drawable="@drawable/icaon" android:duration="10000" />
<item android:drawable="@drawable/icon" android:duration="10000" />
</animation-list>
于 2013-11-28T12:37:23.033 回答
3

要显示上传或下载通知,就像我们在 android 中的默认通知一样(向上或向下箭头分别向上或向下移动喜欢,直到上传或下载完成),只需使用以下内容。

将您的通知生成器设置为,

mBuilder.setSmallIcon(android.R.drawable.stat_sys_download);
mBuilder.setTicker(mContext.getString(R.string.notification_ticker)); //Pass an empty string if you dont want any text to appear on the status bar
//Call notify() method of notification manager to see the effect

当您希望动画图标在上传或下载完成后停止使用时,

 mBuilder.setSmallIcon(R.drawable.ic_download); //ic_download is similar looking icon in your drawable folder
 mNotifyManager.notify(0, mBuilder.build());

希望这可以帮助。:)

于 2014-02-18T10:41:42.883 回答