iOS版百度知道客户端ios 未读消息 角标角标显示数字与实际不符。 如图角标上有114条消息,但是我打开以后里面

Android系统
应用图标显示未读消息数(BadgeNumber) 桌面app图标的角标显示
Android系统 小米,三星,索尼手机发送桌面快键提醒数字图标,在Android系统中,众所周知不支持BadgeNumber,虽然第三方控件
Android系统 小米,三星,索尼手机发送桌面快键提醒数字图标,在Android系统中,众所周知不支持BadgeNumber,虽然第三方控件BadgeView可以实现应用内的数字提醒。
但对于系统的图标,特别是app的logo图标很难实现数字标志,即使是绘图的方式不断修改,但这种方式天生弊端,实用性很差。但幸运的是,某些ROM厂商提供了私有的API,但也带来了难度,API的不同意意味着代码量的增加和兼容性问题更加突出。
我们现在来实现桌面logo或者说icon右上角的图标,先来看2张图,第一张来自互联网,第二张来自个人实践!(由于实验条件有限,只能测试小米的(⊙o⊙)…,有兴趣的同学测试一下其他的吧)
实现原理:
首先我们要明白 并不是应用本身处理对启动图标进行修改、图标的动态修改的过程主要是在Launcher里面完成的.在应用安装,更新,卸载的时候,都会有广播发出,Launcher在LauncherApplication 中注册广播,在LauncherModel中处理接收到广播的消息,重新加载更新应用信息(如:应用图标、文字等)。但是原生的android系统是并不支持该特性的(及不能通过发送特定的系统广播 达到动态修改启动图标的效果),但是在强大的第三方Android手机厂商(如:三星、小米)的系统源码深度定制下、通过修改了Launcher源代码,增加/注册了新的广播接收器用来接收应用发送来的未读消息数广播,接收到广播后,系统将未读消息的数目显示事件交给Launcher去处理,调用相关方法去重绘应用的icon,最终达到动态更新应用图标的效果。
public class MainActivity extends Activity {
//必须使用,Activity启动页
private final static String lancherActivityClassName = Welcome.class.getName();
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(mon_listview_layout);
protected void onResume() {
super.onResume();
sendBadgeNumber();
private void sendBadgeNumber() {
String number = "35";
if (TextUtils.isEmpty(number)) {
number = "0";
int numInt = Integer.valueOf(number);
number = String.valueOf(Math.max(0, Math.min(numInt, 99)));
if (Build.MANUFACTURER.equalsIgnoreCase("Xiaomi")) {
sendToXiaoMi(number);
} else if (Build.MANUFACTURER.equalsIgnoreCase("samsung")) {
sendToSony(number);
} else if (Build.MANUFACTURER.toLowerCase().contains("sony")) {
sendToSamsumg(number);
Toast.makeText(this, "Not Support", Toast.LENGTH_LONG).show();
private void sendToXiaoMi(String number) {
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification =
boolean isMiUIV6 =
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.setContentTitle("您有"+number+"未读消息");
builder.setTicker("您有"+number+"未读消息");
builder.setAutoCancel(true);
builder.setSmallIcon(mon_icon_lamp_light_red);
builder.setDefaults(Notification.DEFAULT_LIGHTS);
notification = builder.build();
//以上代码为notification的初始化信息,在实际应用中,可以单独使用
Class miuiNotificationClass = Class.forName("android.app.MiuiNotification");
Object miuiNotification = miuiNotificationClass.newInstance();
Field field = miuiNotification.getClass().getDeclaredField("messageCount");
field.setAccessible(true);
field.set(miuiNotification, number);// 设置信息数
field = notification.getClass().getField("extraNotification");
field.setAccessible(true);
field.set(notification, miuiNotification);
Toast.makeText(this, "Xiaomi=&isSendOk=&1", Toast.LENGTH_LONG).show();
}catch (Exception e) {
e.printStackTrace();
//miui 6之前的版本
isMiUIV6 =
Intent localIntent = new Intent("android.intent.action.APPLICATION_MESSAGE_UPDATE");
localIntent.putExtra("android.intent.extra.update_application_component_name",getPackageName() + "/"+ lancherActivityClassName );
localIntent.putExtra("android.intent.extra.update_application_message_text",number);
sendBroadcast(localIntent);
if(notification!=null && isMiUIV6 )
//miui6以上版本需要使用通知发送
nm.notify(101010, notification);
private void sendToSony(String number) {
boolean isShow =
if ("0".equals(number)) {
Intent localIntent = new Intent();
localIntent.putExtra("com.sonyericsson.home.intent.extra.badge.SHOW_MESSAGE",isShow);//是否显示
localIntent.setAction("com.sonyericsson.home.action.UPDATE_BADGE");
localIntent.putExtra("com.sonyericsson.home.intent.extra.badge.ACTIVITY_NAME",lancherActivityClassName );//启动页
localIntent.putExtra("com.sonyericsson.home.intent.extra.badge.MESSAGE", number);//数字
localIntent.putExtra("com.sonyericsson.home.intent.extra.badge.PACKAGE_NAME",getPackageName());//包名
sendBroadcast(localIntent);
Toast.makeText(this, "Sony," + "isSendOk", Toast.LENGTH_LONG).show();
private void sendToSamsumg(String number)
Intent localIntent = new Intent("android.intent.action.BADGE_COUNT_UPDATE");
localIntent.putExtra("badge_count", number);//数字
localIntent.putExtra("badge_count_package_name", getPackageName());//包名
localIntent.putExtra("badge_count_class_name",lancherActivityClassName ); //启动页
sendBroadcast(localIntent);
Toast.makeText(this, "Samsumg," + "isSendOk", Toast.LENGTH_LONG).show();
AndroidMainfest.xml配置
注意lancherActivityClassName 必须被配置为 启动页 android.intent.category.LAUNCHER
MIUI 桌面角标官方开源代码简介
MIUI 6上重新设计了桌面app图标的角标显示,基本规则如下:
默认的情况
当app 向通知栏发送了一条通知 (通知不带进度条并且用户可以删除的),那么桌面app icon角标就会显示1.此时app显示的角标数是和通知栏里app发送的通知数对应的,即向通知栏发送了多少通知就会显示多少角标。
通知可以定义角标数
例如 有5封未读邮件,通知栏里只会显示一条通知,但是想让角标显示5. 可以在发通知时加个标示。
第三方app需要用反射来调用,参考代码:
NotificationManager mNotificationManager = (NotificationManager) this
.getSystemService(Context.NOTIFICATION_SERVICE);
Notification.Builder builder = new Notification.Builder(this)
.setContentTitle(“title”).setContentText(“text”).setSmallIcon(R.drawable.icon);
Notification notification = builder.build();
Field field = notification.getClass().getDeclaredField(“extraNotification”);
Object extraNotification = field.get(notification);
Method method = extraNotification.getClass().getDeclaredMethod(“setMessageCount”, int.class);
method.invoke(extraNotification, mCount);
} catch (Exception e) {
e.printStackTrace();
mNotificationManager.notify(0,notification);
封装为工具类
注意:示例源代码中MIUI系统的功能实现和官方介绍的方法不一样,工具类使用的时速官方介绍的方法
这个工具类,是参考,MIUI的我改了一下,测试可以,条件有限,sony和三星未测试
package cn.hdnc.BadgeU
import android.app.N
import android.content.C
import android.content.I
import android.content.pm.PackageM
import android.content.pm.ResolveI
import android.os.B
import android.widget.T
import java.lang.reflect.F
import java.lang.reflect.M
* 应用启动图标未读消息数显示 工具类
(效果如:QQ、微信、未读短信 等应用图标)
* 依赖于第三方手机厂商(如:小米、三星)的Launcher定制、原生系统不支持该特性
* 该工具类 支持的设备有 小米、三星、索尼【其中小米、三星亲测有效、索尼未验证】
* @author ice_
public class BadgeUtil {
* Set badge count
* 针对 Samsung / xiaomi / sony 手机有效
* @param context The context of the application package.
* @param count Badge count to be set
public static void setBadgeCount(Notification notification,Context context, int count) {
if (count &= 0) {
count = 0;
count = Math.max(0, Math.min(count, 99));
if (Build.MANUFACTURER.equalsIgnoreCase("Xiaomi")) {
sendToXiaoMi(notification, context, count);
} else if (Build.MANUFACTURER.equalsIgnoreCase("sony")) {
sendToSony(context, count);
} else if (Build.MANUFACTURER.toLowerCase().contains("samsung")) {
sendToSamsumg(context, count);
Toast.makeText(context, "Not Support", Toast.LENGTH_LONG).show();
* 向小米手机发送未读消息数广播
* @param count
private static void sendToXiaoMi(Notification notification,Context context, int count) {
Class miuiNotificationClass = Class.forName("android.app.MiuiNotification");
Object miuiNotification = miuiNotificationClass.newInstance();
Field field = miuiNotification.getClass().getDeclaredField("messageCount");
field.setAccessible(true);
field.set(miuiNotification, String.valueOf(count == 0 ? "" : count));
// 设置信息数--&这种发送必须是miui 6才行
Field field = notification.getClass().getDeclaredField("extraNotification");
Object extraNotification = field.get(notification);
Method method = extraNotification.getClass().getDeclaredMethod("setMessageCount", int.class);
method.invoke(extraNotification, count);
} catch (Exception e) {
e.printStackTrace();
// miui 6之前的版本
Intent localIntent = new Intent(
"android.intent.action.APPLICATION_MESSAGE_UPDATE");
localIntent.putExtra(
"android.intent.extra.update_application_component_name",
context.getPackageName() + "/" + getLauncherClassName(context));
localIntent.putExtra(
"android.intent.extra.update_application_message_text", String.valueOf(count == 0 ? "" : count));
context.sendBroadcast(localIntent);
* 向索尼手机发送未读消息数广播
* 据说:需添加权限: [未验证]
* @param count
private static void sendToSony(Context context, int count){
String launcherClassName = getLauncherClassName(context);
if (launcherClassName == null) {
boolean isShow =
if (count == 0) {
Intent localIntent = new Intent();
localIntent.setAction("com.sonyericsson.home.action.UPDATE_BADGE");
localIntent.putExtra("com.sonyericsson.home.intent.extra.badge.SHOW_MESSAGE",isShow);//是否显示
localIntent.putExtra("com.sonyericsson.home.intent.extra.badge.ACTIVITY_NAME",launcherClassName );//启动页
localIntent.putExtra("com.sonyericsson.home.intent.extra.badge.MESSAGE", String.valueOf(count));//数字
localIntent.putExtra("com.sonyericsson.home.intent.extra.badge.PACKAGE_NAME", context.getPackageName());//包名
context.sendBroadcast(localIntent);
* 向三星手机发送未读消息数广播
* @param count
private static void sendToSamsumg(Context context, int count){
String launcherClassName = getLauncherClassName(context);
if (launcherClassName == null) {
Intent intent = new Intent("android.intent.action.BADGE_COUNT_UPDATE");
intent.putExtra("badge_count", count);
intent.putExtra("badge_count_package_name", context.getPackageName());
intent.putExtra("badge_count_class_name", launcherClassName);
context.sendBroadcast(intent);
* 重置、清除Badge未读显示数
* @param context
public static void resetBadgeCount(Notification notification,Context context) {
setBadgeCount(notification, context, 0);
* Retrieve launcher activity name of the application from the context
* @param context The context of the application package.
* @return launcher activity name of this application. From the
"android:name" attribute.
private static String getLauncherClassName(Context context) {
PackageManager packageManager = context.getPackageManager();
Intent intent = new Intent(Intent.ACTION_MAIN);
// To limit the components this Intent will resolve to, by setting an
// explicit package name.
intent.setPackage(context.getPackageName());
intent.addCategory(Intent.CATEGORY_LAUNCHER);
// All Application must have 1 Activity at least.
// Launcher activity must be found!
ResolveInfo info = packageManager
.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
// get a ResolveInfo containing ACTION_MAIN, CATEGORY_LAUNCHER
// if there is no Activity which has filtered by CATEGORY_DEFAULT
if (info == null) {
info = packageManager.resolveActivity(intent, 0);
return info.activityInfo.使用其他账号登录
提示:点击上方"IT之家"↑一键关注
我们知道,在iOS系统中,如果某个应用有未读消息,那么在该应用图标右上角就会出现一个带有数字的红色角标提醒用户,其数字的数值则表示该应用未读消息的数目。
红色角标可以直观的展现用户尚未阅读的通知数目,方便用户了解相关信息的整体情况,用户可根据需要选择是否阅读具体内容,这种设计可以说比较贴心。但是对一些强迫症来说,角标简直是要命的,毕竟他们容不得一个角标的存在,尤其当看到角标数字达到成百上千时,若是不点开,他们几乎会疯掉。
那么,问题来了,在iOS系统中,应用上的未读信息角标最大显示会是多少呢?IT之家发现,从QQ来看,其角标达到五位数是没问题的,但是最大上限是多少,我们不得而知。
其实从理论上讲,这个角标最大显示可以是无限大,但一般人应该不会让这个数字一直不停地增大。那么,你遇到过的最大角标是多少呢?
新鲜科技,深度好文,微信中搜索IT之家或扫描二维码关注公众号
本文来自微信公众账号提交,由微信啦收录,转载请注明出处。
微信扫码 分享文章Android系统
应用图标显示未读消息数(BadgeNumber) 桌面app图标的角标显示
Android系统 小米,三星,索尼手机发送桌面快键提醒数字图标,在Android系统中,众所周知不支持BadgeNumber,虽然第三方控件BadgeView可以实现应用内的数字提醒。
但对于系统的图标,特别是app的logo图标很难实现数字标志,即使是绘图的方式不断修改,但这种方式天生弊端,实用性很差。但幸运的是,某些ROM厂商提供了私有的API,但也带来了难度,API的不同意意味着代码量的增加和兼容性问题更加突出。
我们现在来实现桌面logo或者说icon右上角的图标,先来看2张图,第一张来自互联网,第二张来自个人实践!(由于实验条件有限,只能测试小米的(⊙o⊙)&,有兴趣的同学测试一下其他的吧)
实现原理:
首先我们要明白 并不是应用本身处理对启动图标进行修改、图标的动态修改的过程主要是在Launcher里面完成的.在应用安装,更新,卸载的时候,都会有广播发出,Launcher在LauncherApplication 中注册广播,在LauncherModel中处理接收到广播的消息,重新加载更新应用信息(如:应用图标、文字等)。但是原生的android系统是并不支持该特性的(及不能通过发送特定的系统广播 达到动态修改启动图标的效果),但是在强大的第三方Android手机厂商(如:三星、小米)的系统源码深度定制下、通过修改了Launcher源代码,增加/注册了新的广播接收器用来接收应用发送来的未读消息数广播,接收到广播后,系统将未读消息的数目显示事件交给Launcher去处理,调用相关方法去重绘应用的icon,最终达到动态更新应用图标的效果。
public class MainActivity extends Activity {
//必须使用,Activity启动页
private final static String lancherActivityClassName = Welcome.class.getName();
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(mon_listview_layout);
protected void onResume() {
super.onResume();
sendBadgeNumber();
private void sendBadgeNumber() {
String number = &35&;
if (TextUtils.isEmpty(number)) {
number = &0&;
int numInt = Integer.valueOf(number);
number = String.valueOf(Math.max(0, Math.min(numInt, 99)));
if (Build.MANUFACTURER.equalsIgnoreCase(&Xiaomi&)) {
sendToXiaoMi(number);
} else if (Build.MANUFACTURER.equalsIgnoreCase(&samsung&)) {
sendToSony(number);
} else if (Build.MANUFACTURER.toLowerCase().contains(&sony&)) {
sendToSamsumg(number);
Toast.makeText(this, &Not Support&, Toast.LENGTH_LONG).show();
private void sendToXiaoMi(String number) {
NotificationManager nm = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification =
boolean isMiUIV6 =
NotificationCompat.Builder builder = new NotificationCompat.Builder(this);
builder.setContentTitle(&您有&+number+&未读消息&);
builder.setTicker(&您有&+number+&未读消息&);
builder.setAutoCancel(true);
builder.setSmallIcon(mon_icon_lamp_light_red);
builder.setDefaults(Notification.DEFAULT_LIGHTS);
notification = builder.build();
//以上代码为notification的初始化信息,在实际应用中,可以单独使用
Class miuiNotificationClass = Class.forName(&android.app.MiuiNotification&);
Object miuiNotification = miuiNotificationClass.newInstance();
Field field = miuiNotification.getClass().getDeclaredField(&messageCount&);
field.setAccessible(true);
field.set(miuiNotification, number);// 设置信息数
field = notification.getClass().getField(&extraNotification&);
field.setAccessible(true);
field.set(notification, miuiNotification);
Toast.makeText(this, &Xiaomi=&isSendOk=&1&, Toast.LENGTH_LONG).show();
}catch (Exception e) {
e.printStackTrace();
//miui 6之前的版本
isMiUIV6 =
Intent localIntent = new Intent(&android.intent.action.APPLICATION_MESSAGE_UPDATE&);
localIntent.putExtra(&android.intent.extra.update_application_component_name&,getPackageName() + &/&+ lancherActivityClassName );
localIntent.putExtra(&android.intent.extra.update_application_message_text&,number);
sendBroadcast(localIntent);
if(notification!=null && isMiUIV6 )
//miui6以上版本需要使用通知发送
nm.notify(101010, notification);
private void sendToSony(String number) {
boolean isShow =
if (&0&.equals(number)) {
Intent localIntent = new Intent();
localIntent.putExtra(&com.sonyericsson.home.intent.extra.badge.SHOW_MESSAGE&,isShow);//是否显示
localIntent.setAction(&com.sonyericsson.home.action.UPDATE_BADGE&);
localIntent.putExtra(&com.sonyericsson.home.intent.extra.badge.ACTIVITY_NAME&,lancherActivityClassName );//启动页
localIntent.putExtra(&com.sonyericsson.home.intent.extra.badge.MESSAGE&, number);//数字
localIntent.putExtra(&com.sonyericsson.home.intent.extra.badge.PACKAGE_NAME&,getPackageName());//包名
sendBroadcast(localIntent);
Toast.makeText(this, &Sony,& + &isSendOk&, Toast.LENGTH_LONG).show();
private void sendToSamsumg(String number)
Intent localIntent = new Intent(&android.intent.action.BADGE_COUNT_UPDATE&);
localIntent.putExtra(&badge_count&, number);//数字
localIntent.putExtra(&badge_count_package_name&, getPackageName());//包名
localIntent.putExtra(&badge_count_class_name&,lancherActivityClassName ); //启动页
sendBroadcast(localIntent);
Toast.makeText(this, &Samsumg,& + &isSendOk&, Toast.LENGTH_LONG).show();
AndroidMainfest.xml配置
注意lancherActivityClassName 必须被配置为 启动页 android.intent.category.LAUNCHER
MIUI 桌面角标官方开源代码简介
MIUI 6上重新设计了桌面app图标的角标显示,基本规则如下:
默认的情况
当app 向通知栏发送了一条通知 (通知不带进度条并且用户可以删除的),那么桌面app icon角标就会显示1.此时app显示的角标数是和通知栏里app发送的通知数对应的,即向通知栏发送了多少通知就会显示多少角标。
通知可以定义角标数
例如 有5封未读邮件,通知栏里只会显示一条通知,但是想让角标显示5. 可以在发通知时加个标示。
第三方app需要用反射来调用,参考代码:
NotificationManager mNotificationManager = (NotificationManager) this
.getSystemService(Context.NOTIFICATION_SERVICE);
Notification.Builder builder = new Notification.Builder(this)
.setContentTitle(&title&).setContentText(&text&).setSmallIcon(R.drawable.icon);
Notification notification = builder.build();
Field field = notification.getClass().getDeclaredField(&extraNotification&);
Object extraNotification = field.get(notification);
Method method = extraNotification.getClass().getDeclaredMethod(&setMessageCount&, int.class);
method.invoke(extraNotification, mCount);
} catch (Exception e) {
e.printStackTrace();
mNotificationManager.notify(0,notification);
封装为工具类
注意:示例源代码中MIUI系统的功能实现和官方介绍的方法不一样,工具类使用的时速官方介绍的方法
这个工具类,是参考,MIUI的我改了一下,测试可以,条件有限,sony和三星未测试
package cn.hdnc.BadgeU
import android.app.N
import android.content.C
import android.content.I
import android.content.pm.PackageM
import android.content.pm.ResolveI
import android.os.B
import android.widget.T
import java.lang.reflect.F
import java.lang.reflect.M
* 应用启动图标未读消息数显示 工具类
(效果如:QQ、微信、未读短信 等应用图标)
* 依赖于第三方手机厂商(如:小米、三星)的Launcher定制、原生系统不支持该特性
* 该工具类 支持的设备有 小米、三星、索尼【其中小米、三星亲测有效、索尼未验证】
* @author ice_
public class BadgeUtil {
* Set badge count
* 针对 Samsung / xiaomi / sony 手机有效
* @param context The context of the application package.
* @param count Badge count to be set
public static void setBadgeCount(Notification notification,Context context, int count) {
if (count &= 0) {
count = 0;
count = Math.max(0, Math.min(count, 99));
if (Build.MANUFACTURER.equalsIgnoreCase(&Xiaomi&)) {
sendToXiaoMi(notification, context, count);
} else if (Build.MANUFACTURER.equalsIgnoreCase(&sony&)) {
sendToSony(context, count);
} else if (Build.MANUFACTURER.toLowerCase().contains(&samsung&)) {
sendToSamsumg(context, count);
Toast.makeText(context, &Not Support&, Toast.LENGTH_LONG).show();
* 向小米手机发送未读消息数广播
* @param count
private static void sendToXiaoMi(Notification notification,Context context, int count) {
Class miuiNotificationClass = Class.forName(&android.app.MiuiNotification&);
Object miuiNotification = miuiNotificationClass.newInstance();
Field field = miuiNotification.getClass().getDeclaredField(&messageCount&);
field.setAccessible(true);
field.set(miuiNotification, String.valueOf(count == 0 ? && : count));
// 设置信息数--&这种发送必须是miui 6才行
Field field = notification.getClass().getDeclaredField(&extraNotification&);
Object extraNotification = field.get(notification);
Method method = extraNotification.getClass().getDeclaredMethod(&setMessageCount&, int.class);
method.invoke(extraNotification, count);
} catch (Exception e) {
e.printStackTrace();
// miui 6之前的版本
Intent localIntent = new Intent(
&android.intent.action.APPLICATION_MESSAGE_UPDATE&);
localIntent.putExtra(
&android.intent.extra.update_application_component_name&,
context.getPackageName() + &/& + getLauncherClassName(context));
localIntent.putExtra(
&android.intent.extra.update_application_message_text&, String.valueOf(count == 0 ? && : count));
context.sendBroadcast(localIntent);
* 向索尼手机发送未读消息数广播
* 据说:需添加权限: [未验证]
* @param count
private static void sendToSony(Context context, int count){
String launcherClassName = getLauncherClassName(context);
if (launcherClassName == null) {
boolean isShow =
if (count == 0) {
Intent localIntent = new Intent();
localIntent.setAction(&com.sonyericsson.home.action.UPDATE_BADGE&);
localIntent.putExtra(&com.sonyericsson.home.intent.extra.badge.SHOW_MESSAGE&,isShow);//是否显示
localIntent.putExtra(&com.sonyericsson.home.intent.extra.badge.ACTIVITY_NAME&,launcherClassName );//启动页
localIntent.putExtra(&com.sonyericsson.home.intent.extra.badge.MESSAGE&, String.valueOf(count));//数字
localIntent.putExtra(&com.sonyericsson.home.intent.extra.badge.PACKAGE_NAME&, context.getPackageName());//包名
context.sendBroadcast(localIntent);
* 向三星手机发送未读消息数广播
* @param count
private static void sendToSamsumg(Context context, int count){
String launcherClassName = getLauncherClassName(context);
if (launcherClassName == null) {
Intent intent = new Intent(&android.intent.action.BADGE_COUNT_UPDATE&);
intent.putExtra(&badge_count&, count);
intent.putExtra(&badge_count_package_name&, context.getPackageName());
intent.putExtra(&badge_count_class_name&, launcherClassName);
context.sendBroadcast(intent);
* 重置、清除Badge未读显示数
* @param context
public static void resetBadgeCount(Notification notification,Context context) {
setBadgeCount(notification, context, 0);
* Retrieve launcher activity name of the application from the context
* @param context The context of the application package.
* @return launcher activity name of this application. From the
&android:name& attribute.
private static String getLauncherClassName(Context context) {
PackageManager packageManager = context.getPackageManager();
Intent intent = new Intent(Intent.ACTION_MAIN);
// To limit the components this Intent will resolve to, by setting an
// explicit package name.
intent.setPackage(context.getPackageName());
intent.addCategory(Intent.CATEGORY_LAUNCHER);
// All Application must have 1 Activity at least.
// Launcher activity must be found!
ResolveInfo info = packageManager
.resolveActivity(intent, PackageManager.MATCH_DEFAULT_ONLY);
// get a ResolveInfo containing ACTION_MAIN, CATEGORY_LAUNCHER
// if there is no Activity which has filtered by CATEGORY_DEFAULT
if (info == null) {
info = packageManager.resolveActivity(intent, 0);
return info.activityInfo.
(window.slotbydup=window.slotbydup || []).push({
id: '2467140',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467141',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467143',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467148',
container: s,
size: '1000,90',
display: 'inlay-fix'}

我要回帖

更多关于 街头篮球客户端不符 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信