当前位置: 首页>>代码示例>>Java>>正文


Java ApplicationInfo.FLAG_SYSTEM属性代码示例

本文整理汇总了Java中android.content.pm.ApplicationInfo.FLAG_SYSTEM属性的典型用法代码示例。如果您正苦于以下问题:Java ApplicationInfo.FLAG_SYSTEM属性的具体用法?Java ApplicationInfo.FLAG_SYSTEM怎么用?Java ApplicationInfo.FLAG_SYSTEM使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.content.pm.ApplicationInfo的用法示例。


在下文中一共展示了ApplicationInfo.FLAG_SYSTEM属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: isSystemApplication

/**
 * 判断是否是系统App
 *
 * @param context
 * @param packageName 包名
 * @return
 */
public static boolean isSystemApplication(Context context, String packageName) {
    if (context == null) {
        return false;
    }
    PackageManager packageManager = context.getPackageManager();
    if (packageManager == null || packageName == null || packageName.length() == 0) {
        return false;
    }

    try {
        ApplicationInfo app = packageManager.getApplicationInfo(packageName, 0);
        return (app != null && (app.flags & ApplicationInfo.FLAG_SYSTEM) > 0);
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }
    return false;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:24,代码来源:Kits.java

示例2: getAllApps

/**
 * 获取系统中所有的应用
 *
 * @param context 上下文
 * @return 应用信息List
 */
public static List<PackageInfo> getAllApps(Context context) {

    List<PackageInfo> apps = new ArrayList<PackageInfo>();
    PackageManager pManager = context.getPackageManager();
    List<PackageInfo> paklist = pManager.getInstalledPackages(0);
    for (int i = 0; i < paklist.size(); i++) {
        PackageInfo pak = paklist.get(i);
        if ((pak.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) <=
                0) {
            // customs applications
            apps.add(pak);
        }
    }
    return apps;
}
 
开发者ID:weileng11,项目名称:KUtils-master,代码行数:21,代码来源:Utils.java

示例3: getSingleSystemActivity

private ResolveInfo getSingleSystemActivity(List<ResolveInfo> appList) {
    ResolveInfo systemResolve = null;
    final int N = appList.size();
    for (int i = 0; i < N; ++i) {
        try {
            ApplicationInfo info = mPackageManager.getApplicationInfo(
                    appList.get(i).activityInfo.packageName, 0);
            if ((info.flags & ApplicationInfo.FLAG_SYSTEM) != 0) {
                if (systemResolve != null) {
                    return null;
                } else {
                    systemResolve = appList.get(i);
                }
            }
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
            return null;
        }
    }
    return systemResolve;
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:21,代码来源:DefaultLayoutParser.java

示例4: isSysApp

public static boolean isSysApp(Context context, String pkgName) {
        if (context == null || TextUtils.isEmpty(pkgName)) {
            return false;
        }

        try {
            PackageManager packageManager = context.getPackageManager();
            ApplicationInfo applicationInfo = packageManager.getPackageInfo(pkgName, 0).applicationInfo;
//            return (applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == ApplicationInfo.FLAG_SYSTEM;
            return ((ApplicationInfo.FLAG_SYSTEM | ApplicationInfo.FLAG_UPDATED_SYSTEM_APP)
                    & applicationInfo.flags) != 0;
        } catch (Exception e) {
            e.printStackTrace();
        }

        return false;
    }
 
开发者ID:by-syk,项目名称:NanoIconPack,代码行数:17,代码来源:PkgUtil.java

示例5: getAllApps

/**
 * 查询手机内非系统应用
 *
 * @param context
 * @return
 */
public static List<PackageInfo> getAllApps(Context context) {
    List<PackageInfo> apps = new ArrayList<PackageInfo>();
    PackageManager pManager = context.getPackageManager();
    // 获取手机内所有应用
    List<PackageInfo> paklist = pManager.getInstalledPackages(0);
    for (int i = 0; i < paklist.size(); i++) {
        PackageInfo pak = paklist.get(i);
        // 判断是否为非系统预装的应用程序
        if ((pak.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) <= 0) {
            // customs applications
            apps.add(pak);
        }
    }
    return apps;
}
 
开发者ID:junchenChow,项目名称:exciting-app,代码行数:21,代码来源:CommonUtil.java

示例6: getNameOfAppsArray

public ArrayList<String> getNameOfAppsArray() {
    PackageManager pm = context.getPackageManager();
    listOfAppInfo = pm.getInstalledApplications(pm.GET_META_DATA);
    for(ApplicationInfo app : listOfAppInfo) {

        if(pm.getLaunchIntentForPackage(app.packageName) != null) {
            // apps with launcher intent
            if((app.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) == 1) {
                // updated system apps

            } else if ((app.flags & ApplicationInfo.FLAG_SYSTEM) == 1) {
                // system apps

            } else {
                // user installed apps
                nameOfAppsArray.add((String) pm.getApplicationLabel(app));
            }
        }
    }
    return nameOfAppsArray;
}
 
开发者ID:01sadra,项目名称:Detoxiom,代码行数:21,代码来源:AppNameAndLogoProvider.java

示例7: scanLocalInstallAppList

public static List<MyAppInfo> scanLocalInstallAppList(PackageManager packageManager, boolean isFilter) {
    List<MyAppInfo> myAppInfos = new ArrayList<MyAppInfo>();
    try {
        List<PackageInfo> packageInfos = packageManager.getInstalledPackages(0);
        for (int i = 0; i < packageInfos.size(); i++) {
            PackageInfo packageInfo = packageInfos.get(i);
            //过滤掉系统app
            if (isFilter && (ApplicationInfo.FLAG_SYSTEM & packageInfo.applicationInfo.flags) != 0) {
                continue;
            }
            MyAppInfo myAppInfo = new MyAppInfo();
            myAppInfo.setPkgName(packageInfo.applicationInfo.loadLabel(packageManager).toString());

            myAppInfo.setAppName(packageInfo.packageName);
            if (packageInfo.applicationInfo.loadIcon(packageManager) == null) {
                continue;
            }
            myAppInfo.setImage(packageInfo.applicationInfo.loadIcon(packageManager));
            myAppInfos.add(myAppInfo);
        }
    } catch (Exception e) {
        Log.e(TAG, "===============获取应用包信息失败");
    }
    return myAppInfos;
}
 
开发者ID:littleRich,项目名称:VirtualLocation,代码行数:25,代码来源:ApkTool.java

示例8: getNativeLibraryDirectory

/**
 * @return the path to native libraries.
 */
@SuppressWarnings("unused")
@CalledByNative
private static String getNativeLibraryDirectory(Context appContext) {
    ApplicationInfo ai = appContext.getApplicationInfo();
    if ((ai.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0
            || (ai.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
        return ai.nativeLibraryDir;
    }

    return "/system/lib/";
}
 
开发者ID:lizhangqu,项目名称:chromium-net-for-android,代码行数:14,代码来源:PathUtils.java

示例9: isSystemApp

/**
 * 判断 App 是否是系统应用
 *
 * @param packageName 包名
 * @return {@code true}: 是<br>{@code false}: 否
 */
public static boolean isSystemApp(final String packageName) {
    try {
        PackageManager pm = UtilManager.getContext().getPackageManager();
        ApplicationInfo ai = pm.getApplicationInfo(packageName, 0);
        return ai != null && (ai.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
        return false;
    }
}
 
开发者ID:sundevin,项目名称:utilsLibrary,代码行数:16,代码来源:DeviceInfo.java

示例10: isSystemApplication

/**
 * whether packageName is system application
 */
public static boolean isSystemApplication(Context context, String packageName) {
    PackageManager packageManager = context.getPackageManager();
    if (packageManager == null || packageName == null || packageName.length() == 0) {
        return false;
    }
    try {
        ApplicationInfo app = packageManager.getApplicationInfo(packageName, 0);
        return (app != null && (app.flags & ApplicationInfo.FLAG_SYSTEM) > 0);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return false;
}
 
开发者ID:androidDaniel,项目名称:treasure,代码行数:16,代码来源:PackageUtil.java

示例11: isSystemApplication

/**
 * /**
 * whether packageName is system application
 */
public boolean isSystemApplication(Context context) {
    PackageManager packageManager = context.getPackageManager();
    String packageName = context.getPackageName();
    if (packageManager == null || packageName == null || packageName.length() == 0) {
        return false;
    }
    try {
        ApplicationInfo app = packageManager.getApplicationInfo(packageName, 0);
        return (app != null && (app.flags & ApplicationInfo.FLAG_SYSTEM) > 0);
    } catch (Exception e) {
        e.printStackTrace();
    }
    return false;
}
 
开发者ID:jqjm,项目名称:Liteframework,代码行数:18,代码来源:SilentInstaller.java

示例12: performImportIfPossible

/**
 * Performs data import if possible.
 * @return true on successful data import, false if it was not available
 * @throws Exception if the import failed
 */
public static boolean performImportIfPossible(Context context) throws Exception {
    SharedPreferences devicePrefs = getDevicePrefs(context);
    String sourcePackage = devicePrefs.getString(KEY_DATA_IMPORT_SRC_PKG, "");
    String sourceAuthority = devicePrefs.getString(KEY_DATA_IMPORT_SRC_AUTHORITY, "");

    if (TextUtils.isEmpty(sourcePackage) || TextUtils.isEmpty(sourceAuthority)) {
        return false;
    }

    // Synchronously clear the migration flags. This ensures that we do not try migration
    // again and thus prevents potential crash loops due to migration failure.
    devicePrefs.edit().remove(KEY_DATA_IMPORT_SRC_PKG).remove(KEY_DATA_IMPORT_SRC_AUTHORITY).commit();

    if (!Settings.call(context.getContentResolver(), Settings.METHOD_WAS_EMPTY_DB_CREATED)
            .getBoolean(Settings.EXTRA_VALUE, false)) {
        // Only migration if a new DB was created.
        return false;
    }

    for (ProviderInfo info : context.getPackageManager().queryContentProviders(
            null, context.getApplicationInfo().uid, 0)) {

        if (sourcePackage.equals(info.packageName)) {
            if ((info.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0) {
                // Only migrate if the source launcher is also on system image.
                return false;
            }

            // Wait until we found a provider with matching authority.
            if (sourceAuthority.equals(info.authority)) {
                if (TextUtils.isEmpty(info.readPermission) ||
                        context.checkPermission(info.readPermission, Process.myPid(),
                                Process.myUid()) == PackageManager.PERMISSION_GRANTED) {
                    // All checks passed, run the import task.
                    return new ImportDataTask(context, sourceAuthority).importWorkspace();
                }
            }
        }
    }
    return false;
}
 
开发者ID:TeamBrainStorm,项目名称:SimpleUILauncher,代码行数:46,代码来源:ImportDataTask.java

示例13: isSystemApp

/**
 * 判断App是否是系统应用
 *
 * @param context 上下文
 * @param packageName 包名
 */
public static boolean isSystemApp(Context context, final String packageName) {
    if (StringUtil.isSpace(packageName)) return false;
    try {
        PackageManager pm = context.getPackageManager();
        ApplicationInfo ai = pm.getApplicationInfo(packageName, 0);
        return ai != null && (ai.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
        return false;
    }
}
 
开发者ID:senierr,项目名称:ModuleFrame,代码行数:17,代码来源:AppUtil.java

示例14: getBean

/**
 * 得到AppInfo的Bean
 */
private static AppInfo getBean(PackageManager pm, PackageInfo pi) {
    ApplicationInfo ai = pi.applicationInfo;
    String name = ai.loadLabel(pm).toString();
    Drawable icon = ai.loadIcon(pm);
    String packageName = pi.packageName;
    String versionName = pi.versionName;
    int versionCode = pi.versionCode;
    boolean isSD = (ApplicationInfo.FLAG_SYSTEM & ai.flags) != ApplicationInfo.FLAG_SYSTEM;
    boolean isUser = (ApplicationInfo.FLAG_SYSTEM & ai.flags) != ApplicationInfo.FLAG_SYSTEM;
    return new AppInfo(name, icon, packageName, versionName, versionCode, isSD, isUser);
}
 
开发者ID:zhuangzaiku,项目名称:AndroidCollection,代码行数:14,代码来源:AppUtils.java

示例15: onReceive

@Override
public void onReceive(Context context, Intent intent) {
    boolean findApp = false;
    if (intent.getAction().equals(action_boot)) {
        Log.i(logTag, "Receive " + action_boot);
        Intent mBootIntent = new Intent(context, AutoBootKodi.class);
        mBootIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(mBootIntent);
        Log.i(logTag, "Done!");
        String intentName = new String("");
        PackageManager packageManager = context.getPackageManager();
        ArrayList<AppInfo> appList = new ArrayList<AppInfo>();
        List<PackageInfo> packages = packageManager.getInstalledPackages(0);
        for(int i = 0;i < packages.size();i++) {
            PackageInfo packageInfo = packages.get(i);
            AppInfo tempInfo = new AppInfo();
            tempInfo.appName = packageInfo.applicationInfo.loadLabel(packageManager).toString();
            tempInfo.packageName = packageInfo.packageName;
            tempInfo.versionName = packageInfo.versionName;
            tempInfo.versionCode = packageInfo.versionCode;
            tempInfo.appIcon = packageInfo.applicationInfo.loadIcon(packageManager);
            // if want to launch the app not system app, add below judgement
            if((packageInfo.applicationInfo.flags & ApplicationInfo.FLAG_SYSTEM) == 0)
            {
                if (tempInfo.packageName.equals("org.xbmc.xbmc")) {
                    intentName = new String(context.getResources().getString(R.string.boot_app_name) +
                            context.getResources().getString(R.string.old_app_name));
                    findApp =true;
                } else if (tempInfo.packageName.equals("org.xbmc.kodi")) {
                    intentName = new String(context.getResources().getString(R.string.boot_app_name) +
                            context.getResources().getString(R.string.new_app_name));
                    findApp =true;
                }
                if (findApp) {
                    appList.add(tempInfo);
                    Log.i(logTag, "intentName is " + intentName);
                    tempInfo.print();
                }
            }
        }

        if (findApp) { // should use flag findApp to check the intentName has string or null
            Intent mBootUpIntent = packageManager.getLaunchIntentForPackage(intentName);
            mBootUpIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(mBootUpIntent);
        }

    }

}
 
开发者ID:Sl0v3C,项目名称:Android_AutobootKodi,代码行数:50,代码来源:Receiver.java


注:本文中的android.content.pm.ApplicationInfo.FLAG_SYSTEM属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。