如何在android中闪烁通知图标?[完毕] [英] How to blink notification icon in android? [DONE]
本文介绍了如何在android中闪烁通知图标?[完毕]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我搜索了很多类似的东西:如何在谷歌地图上显示闪烁的图标
I searched many things as like : How to show icon blinking on google map
但是根据这个我没有找到如何使通知图标闪烁
but according to this i don't find how to blink notification icon blink
我想在这个上闪烁图标
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);
推荐答案
我找到了解决方案:我创建了动画文件并设置了该文件,谢谢我找到了解决方案
i found solution :i created animation file and set that file , thanks i found solution
在此处设置文件名称:-
SET FILE name here:-
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>
这篇关于如何在android中闪烁通知图标?[完毕]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文