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


Java PackageManager.getApplicationInfo方法代码示例

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


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

示例1: getIconPacks

import android.content.pm.PackageManager; //导入方法依赖的package包/类
public Map<String, String> getIconPacks() {
	Map<String, String> iconPacks = new HashMap<String, String>();
	PackageManager pm = context.getPackageManager();
	List<ResolveInfo> iconPacksInfo = pm.queryIntentActivities(new Intent("org.adw.launcher.THEMES"), PackageManager.GET_META_DATA);
	String iconPackPackage = null;
	String iconPackName = null;
	for (ResolveInfo info: iconPacksInfo) {
		iconPackPackage = info.activityInfo.packageName;
		ApplicationInfo ai = null;
		try {
			ai = pm.getApplicationInfo(iconPackPackage, PackageManager.GET_META_DATA);
			iconPackName = pm.getApplicationLabel(ai).toString();
		} catch (PackageManager.NameNotFoundException e) {}
		iconPacks.put(iconPackName, iconPackPackage);
	}
	return iconPacks;
}
 
开发者ID:HenriDellal,项目名称:emerald,代码行数:18,代码来源:IconPackManager.java

示例2: initApplicationInfoBase

import android.content.pm.PackageManager; //导入方法依赖的package包/类
public static void initApplicationInfoBase(PackageSetting ps, VPackage p) {
    ApplicationInfo ai = p.applicationInfo;
    ai.flags |= ApplicationInfo.FLAG_HAS_CODE;
    if (TextUtils.isEmpty(ai.processName)) {
        ai.processName = ai.packageName;
    }
    ai.enabled = true;
    ai.nativeLibraryDir = ps.libPath;
    ai.uid = ps.appId;
    ai.name = ComponentFixer.fixComponentClassName(ps.packageName, ai.name);
    ai.publicSourceDir = ps.apkPath;
    ai.sourceDir = ps.apkPath;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        ai.splitSourceDirs = new String[]{ps.apkPath};
        ai.splitPublicSourceDirs = ai.splitSourceDirs;
        ApplicationInfoL.scanSourceDir.set(ai, ai.dataDir);
        ApplicationInfoL.scanPublicSourceDir.set(ai, ai.dataDir);
        String hostPrimaryCpuAbi = ApplicationInfoL.primaryCpuAbi.get(VirtualCore.get().getContext().getApplicationInfo());
        ApplicationInfoL.primaryCpuAbi.set(ai, hostPrimaryCpuAbi);
    }

    if (ps.dependSystem) {
        String[] sharedLibraryFiles = sSharedLibCache.get(ps.packageName);
        if (sharedLibraryFiles == null) {
            PackageManager hostPM = VirtualCore.get().getUnHookPackageManager();
            try {
                ApplicationInfo hostInfo = hostPM.getApplicationInfo(ps.packageName, PackageManager.GET_SHARED_LIBRARY_FILES);
                sharedLibraryFiles = hostInfo.sharedLibraryFiles;
                if (sharedLibraryFiles == null) sharedLibraryFiles = new String[0];
                sSharedLibCache.put(ps.packageName, sharedLibraryFiles);
            } catch (PackageManager.NameNotFoundException e) {
                e.printStackTrace();
            }
        }
        ai.sharedLibraryFiles = sharedLibraryFiles;
    }
}
 
开发者ID:coding-dream,项目名称:TPlayer,代码行数:38,代码来源:PackageParserEx.java

示例3: onReceivedSslError

import android.content.pm.PackageManager; //导入方法依赖的package包/类
/**
 * Notify the host application that an SSL error occurred while loading a resource.
 * The host application must call either handler.cancel() or handler.proceed().
 * Note that the decision may be retained for use in response to future SSL errors.
 * The default behavior is to cancel the load.
 *
 * @param view          The WebView that is initiating the callback.
 * @param handler       An SslErrorHandler object that will handle the user's response.
 * @param error         The SSL error object.
 */
@TargetApi(8)
@Override
public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) {

    final String packageName = parentEngine.cordova.getActivity().getPackageName();
    final PackageManager pm = parentEngine.cordova.getActivity().getPackageManager();

    ApplicationInfo appInfo;
    try {
        appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA);
        if ((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
            // debug = true
            handler.proceed();
            return;
        } else {
            // debug = false
            super.onReceivedSslError(view, handler, error);
        }
    } catch (NameNotFoundException e) {
        // When it doubt, lock it out!
        super.onReceivedSslError(view, handler, error);
    }
}
 
开发者ID:jie-meng,项目名称:DinningShare,代码行数:34,代码来源:SystemWebViewClient.java

示例4: isSystemApplication

import android.content.pm.PackageManager; //导入方法依赖的package包/类
/**
 * 判断是否是系统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:lzmlsfe,项目名称:19porn,代码行数:25,代码来源:Kits.java

示例5: doInBackground

import android.content.pm.PackageManager; //导入方法依赖的package包/类
@Override
protected Set<AppInfo> doInBackground(Void... params) {
    PreventActivity pa = wr.get();
    Set<AppInfo> applications = new TreeSet<AppInfo>();
    if (pa == null) {
        return applications;
    }
    PackageManager pm = pa.getPackageManager();
    Map<String, Set<Long>> running = pa.getRunningProcesses();
    int i = 1;
    for (String name : mAdapter.getNames()) {
        publishProgress(++i);
        ApplicationInfo info;
        try {
            info = pm.getApplicationInfo(name, 0);
        } catch (NameNotFoundException e) { // NOSONAR
            info = null;
        }
        if (info == null || !info.enabled) {
            continue;
        }
        String label = labelLoader.loadLabel(info);
        applications.add(new AppInfo(name, label, running.get(name)).setFlags(info.flags));
    }
    return applications;
}
 
开发者ID:brevent,项目名称:prevent,代码行数:27,代码来源:PreventFragment.java

示例6: isSystemApp

import android.content.pm.PackageManager; //导入方法依赖的package包/类
/**
 * 判断App是否是系统应用
 *
 * @param packageName 包名
 * @return {@code true}: 是<br>{@code false}: 否
 */
public static boolean isSystemApp(final String packageName) {
    if (isSpace(packageName)) return false;
    try {
        PackageManager pm = Utils.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:Wilshion,项目名称:HeadlineNews,代码行数:18,代码来源:AppUtils.java

示例7: newFacebookIntent

import android.content.pm.PackageManager; //导入方法依赖的package包/类
public static Intent newFacebookIntent(PackageManager pm, String url) {
    Uri uri = Uri.parse(url);
    try {
        ApplicationInfo applicationInfo = pm.getApplicationInfo("com.facebook.katana", 0);
        if (applicationInfo.enabled) {
            // http://stackoverflow.com/a/24547437/1048340
            uri = Uri.parse("fb://facewebmodal/f?href="+url);
        }
    } catch (PackageManager.NameNotFoundException ignored) {
        facebook_not_found=true;
    }
    return new Intent(Intent.ACTION_VIEW, uri);
}
 
开发者ID:Ronak-59,项目名称:Trinity-App,代码行数:14,代码来源:MainActivity.java

示例8: getAppMetadataBy

import android.content.pm.PackageManager; //导入方法依赖的package包/类
@ReactMethod
public void getAppMetadataBy(String key, Promise promise) {
    PackageManager pm = this.reactContext.getPackageManager();
    String value = null;
    try {
        ApplicationInfo pInfo = pm.getApplicationInfo(this.packageName, PackageManager.GET_META_DATA);
        value = pInfo.metaData.getString(key);
        promise.resolve(value);
    } catch (PackageManager.NameNotFoundException e) {
        //e.printStackTrace();
        Log.e("[RNAppMetadata]", " name not found");
        promise.resolve(e);
    }
}
 
开发者ID:CubeSugar,项目名称:react-native-app-metadata,代码行数:15,代码来源:RNAppMetadataModule.java

示例9: setUpdateTime

import android.content.pm.PackageManager; //导入方法依赖的package包/类
/**
 * Set update time from apk file modification time.
 */
private static void setUpdateTime(Map<String, Object> params, PackageManager packageManager,
    String packageName) {
  try {
    ApplicationInfo info = packageManager.getApplicationInfo(packageName, 0);
    File apkFile = new File(info.sourceDir);
    if (apkFile.exists()) {
      params.put(Constants.Params.UPDATE_DATE, "" + (apkFile.lastModified() / 1000.0));
    }
  } catch (Throwable t) {
    Log.w("Failed to find package info: " + t);
  }
}
 
开发者ID:Leanplum,项目名称:Leanplum-Android-SDK,代码行数:16,代码来源:Util.java

示例10: hasUsageAccess

import android.content.pm.PackageManager; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.KITKAT)
private boolean hasUsageAccess() {
    try {
        PackageManager packageManager = getPackageManager();
        ApplicationInfo applicationInfo = packageManager.getApplicationInfo(getPackageName(), 0);
        AppOpsManager appOpsManager = (AppOpsManager) getSystemService(Context.APP_OPS_SERVICE);
        int mode = appOpsManager.checkOpNoThrow(AppOpsManager.OPSTR_GET_USAGE_STATS, applicationInfo.uid, applicationInfo.packageName);
        return (mode == AppOpsManager.MODE_ALLOWED);

    } catch (PackageManager.NameNotFoundException e) {
        return false;
    }
}
 
开发者ID:shivamsingh,项目名称:lockit,代码行数:14,代码来源:HomeActivity.java

示例11: getAppName

import android.content.pm.PackageManager; //导入方法依赖的package包/类
/**
 * Gets the name of the application
 *
 * @param context     context
 * @param packagename Application package name
 * @return App name
 */
public String getAppName(Context context, String packagename) {
    //Package management operations management class
    PackageManager pm = context.getPackageManager();
    try {
        ApplicationInfo info = pm.getApplicationInfo(packagename, 0);
        return info.loadLabel(pm).toString();
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();

    }
    return packagename;
}
 
开发者ID:Jusenr,项目名称:androidtools,代码行数:20,代码来源:AppUtils.java

示例12: isSystemApplication

import android.content.pm.PackageManager; //导入方法依赖的package包/类
/**
 * /**
 * 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:wzx54321,项目名称:XinFramework,代码行数:19,代码来源:SilentInstaller.java

示例13: getIcon

import android.content.pm.PackageManager; //导入方法依赖的package包/类
private int getIcon(Context context) {

            final PackageManager packageManager = context.getPackageManager();
            ApplicationInfo appInfo = null;
            try {
                appInfo = packageManager.getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);
            } catch (PackageManager.NameNotFoundException e) {
                e.printStackTrace();
            }
            if (appInfo != null) {
                return appInfo.icon;
            }
            return 0;
        }
 
开发者ID:z-chu,项目名称:FriendBook,代码行数:15,代码来源:UpdateService.java

示例14: isAppDebug

import android.content.pm.PackageManager; //导入方法依赖的package包/类
/**
 * 判断App是否是Debug版本
 *
 * @return {@code true}: 是<br>{@code false}: 否
 */
public static boolean isAppDebug() {
    if (StringUtils.isSpace(context.getPackageName())) return false;
    try {
        PackageManager pm = context.getPackageManager();
        ApplicationInfo ai = pm.getApplicationInfo(context.getPackageName(), 0);
        return ai != null && (ai.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
        return false;
    }
}
 
开发者ID:guiying712,项目名称:AndroidModulePattern,代码行数:17,代码来源:Utils.java

示例15: getResources

import android.content.pm.PackageManager; //导入方法依赖的package包/类
Resources getResources(Context context) {
    PackageManager packageManager = context.getPackageManager();
    Resources res = null;
    try {
        ApplicationInfo appInfo = packageManager.getApplicationInfo(mPackageName, 0);
        res = packageManager.getResourcesForApplication(appInfo);
    } catch (NameNotFoundException e) {
        Log.i(TAG, "couldn't get resources");
    }
    return res;
}
 
开发者ID:PhilippC,项目名称:keepass2android,代码行数:12,代码来源:PluginManager.java


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