IOS开发隐藏状态栏(电池栏)

方法一:

boolean isMyLauncherDefault() {
    final IntentFilter filter = new IntentFilter(Intent.ACTION_MAIN);
    filter.addCategory(Intent.CATEGORY_HOME);

    List<IntentFilter> filters = new ArrayList<IntentFilter>();
    filters.add(filter);

    final String myPackageName = getPackageName();
    List<ComponentName> activities = new ArrayList<ComponentName>();
    final PackageManager packageManager = (PackageManager) getPackageManager();

    // You can use name of your package here as third argument
    packageManager.getPreferredActivities(filters, activities, null);

    for (ComponentName activity : activities) {
        if (myPackageName.equals(activity.getPackageName())) {
            return true;
        }
    }
    return false;
}

方法二

public boolean isMyAppLauncherDefault() {
    IntentFilter filter = new IntentFilter(Intent.ACTION_MAIN);
    filter.addCategory(Intent.CATEGORY_HOME);
 
    List<IntentFilter> filters = new ArrayList<IntentFilter>();
    filters.add(filter);
 
    // the packageName of your application
    String packageName = getPackageName();
    List<ComponentName> preferredActivities = new ArrayList<ComponentName>();
    final PackageManager packageManager = (PackageManager) getPackageManager();
 
    // You can use name of your package here as third argument
    packageManager.getPreferredActivities(filters, preferredActivities, packageName);
 
    if (preferredActivities != null && preferredActivities.size()> 0) {
        return true;
    }
    return false;
}
 



http://www.android-ios-tutorials.com/225/get-default-launcher-pogrammatically-android/

http://*.com/questions/10188954/start-launcher-selection-programmatically-android

IOS开发隐藏状态栏(电池栏),布布扣,bubuko.com

IOS开发隐藏状态栏(电池栏)

上一篇:JS与Android互调


下一篇:判断Android中应用是否为默认启动的方法