http://blog.csdn.net/janice0529/article/details/44344169
Android系统 小米,三星,索尼手机发送桌面快键提醒数字图标,在Android系统中,众所周知不支持BadgeNumber,虽然第三方控件BadgeView可以实现应用内的数字提醒,但对于系统的图标,特别是app的logo图标很难实现数字标志,即使是绘图的方式不断修改,但这种方式天生弊端,实用性很差。但幸运的是,某些ROM厂商提供了私有的API,但也带来了难度,API的不同意意味着代码量的增加和兼容性问题更加突出。
我们现在来实现桌面logo或者说icon右上角的图标,先来看2张图,第一张来自互联网,第二张来自个人实践!(由于实验条件有限,只能测试小米的(⊙o⊙)…,有兴趣的同学测试一下其他的吧)
好了,上代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
|
setContentView(R.layout.common_listview_layout);
}
sendBadgeNumber();
}
String number =
number =
}
number = String.valueOf(Math.max(
}
sendToXiaoMi(number);
}
sendToSony(number);
}
sendToSamsumg(number);
}
Toast.makeText(
}
}
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification =
NotificationCompat.Builder builder =
builder.setContentTitle(
builder.setTicker(
builder.setAutoCancel(
builder.setSmallIcon(R.drawable.common_icon_lamp_light_red);
builder.setDefaults(Notification.DEFAULT_LIGHTS);
notification = builder.build();
Class miuiNotificationClass = Class.forName(
Object miuiNotification = miuiNotificationClass.newInstance();
Field field = miuiNotification.getClass().getDeclaredField(
field.setAccessible(
field.set(miuiNotification, number);
field = notification.getClass().getField(
field.setAccessible(
field.set(notification, miuiNotification);
Toast.makeText(
}
e.printStackTrace();
isMiUIV6 =
Intent localIntent =
localIntent.putExtra(
localIntent.putExtra(
sendBroadcast(localIntent);
}
{
{
nm.notify(
}
}
}
isShow =
}
Intent localIntent =
localIntent.putExtra(
localIntent.setAction(
localIntent.putExtra(
localIntent.putExtra(
localIntent.putExtra(
sendBroadcast(localIntent);
Toast.makeText(
}
{
Intent localIntent =
localIntent.putExtra(
localIntent.putExtra(
localIntent.putExtra(
sendBroadcast(localIntent);
Toast.makeText(
}
}
|
注意lancherActivityClassName 必须被配置为 启动页 android.intent.category.LAUNCHER
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
|
相互学习,共同进步!
联系方式:240803830
主页:http://www.cnblogs.com/taoboy/