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


Java PackageManager.NameNotFoundException方法代码示例

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


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

示例1: appVersionCode

import android.content.pm.PackageManager; //导入方法依赖的package包/类
public static String appVersionCode(Context context) {
    PackageManager pm = context.getPackageManager();
    PackageInfo pi = null;
    try {
        pi = pm.getPackageInfo(context.getPackageName(), PackageManager.GET_ACTIVITIES);
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
        return "unknown";
    }
    return pi.versionCode + "";
}
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:12,代码来源:Device.java

示例2: preloadIcon

import android.content.pm.PackageManager; //导入方法依赖的package包/类
/**
 * Pre-load an icon into the persistent cache.
 *
 * <P>Queries for a component that does not exist in the package manager
 * will be answered by the persistent cache.
 *
 * @param componentName the icon should be returned for this component
 * @param icon the icon to be persisted
 * @param dpi the native density of the icon
 */
public void preloadIcon(ComponentName componentName, Bitmap icon, int dpi, String label,
        long userSerial, InvariantDeviceProfile idp) {
    // TODO rescale to the correct native DPI
    try {
        PackageManager packageManager = mContext.getPackageManager();
        packageManager.getActivityIcon(componentName);
        // component is present on the system already, do nothing
        return;
    } catch (PackageManager.NameNotFoundException e) {
        // pass
    }

    icon = Bitmap.createScaledBitmap(icon, idp.iconBitmapSize, idp.iconBitmapSize, true);
    Bitmap lowResIcon = generateLowResIcon(icon, Color.TRANSPARENT);
    ContentValues values = newContentValues(icon, lowResIcon, label,
            componentName.getPackageName());
    values.put(IconDB.COLUMN_COMPONENT, componentName.flattenToString());
    values.put(IconDB.COLUMN_USER, userSerial);
    mIconDb.insertOrReplace(values);
}
 
开发者ID:TeamBrainStorm,项目名称:SimpleUILauncher,代码行数:31,代码来源:IconCache.java

示例3: getAppVersionCode

import android.content.pm.PackageManager; //导入方法依赖的package包/类
/**
     * 返回app的版本代码.
     *
     * @param context the context
     * @return app version code
     */
    public static int getAppVersionCode(Context context) {
// 获取package manager的实例
        PackageManager packageManager = context.getPackageManager();
// getPackageName()是你当前类的包名,0代表是获取版本信息
        int code = 1;
        PackageInfo packInfo;
        try {
            packInfo = packageManager.getPackageInfo(context.getPackageName(),
                    0);
            code = packInfo.versionCode;
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
// Log.i("版本代码:", version);
        return code;
    }
 
开发者ID:angcyo,项目名称:RLibrary,代码行数:23,代码来源:RUtils.java

示例4: isAppInstalled

import android.content.pm.PackageManager; //导入方法依赖的package包/类
private boolean isAppInstalled(String packageName) {
    PackageManager pm = getPackageManager();
    boolean installed = false;
    try {
        pm.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES);
        installed = true;
    } catch (PackageManager.NameNotFoundException e) {
        installed = false;
    }
    return installed;
}
 
开发者ID:ayc3ue,项目名称:NotificationsApp,代码行数:12,代码来源:MainActivity.java

示例5: getVersionName

import android.content.pm.PackageManager; //导入方法依赖的package包/类
/**
 * 获取当前版本
 *
 * @param context
 * @return
 */
public static String getVersionName(Context context) {
    PackageManager pManager = context.getPackageManager();
    PackageInfo packageInfo = null;
    try {
        packageInfo = pManager.getPackageInfo(context.getPackageName(), 0);
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }
    return packageInfo.versionName;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:Kits.java

示例6: isPackageExist

import android.content.pm.PackageManager; //导入方法依赖的package包/类
/**
 * 当前的包是否存在
 *
 * @param context
 * @param pckName
 * @return
 */
public static boolean isPackageExist(Context context, String pckName) {
    try {
        PackageInfo pckInfo = context.getPackageManager()
                .getPackageInfo(pckName, 0);
        if (pckInfo != null)
            return true;
    } catch (PackageManager.NameNotFoundException e) {
        Log.e("TDvice", e.getMessage());
    }
    return false;
}
 
开发者ID:Wan7451,项目名称:mvparms,代码行数:19,代码来源:DeviceUtils.java

示例7: isFrameworkPackage

import android.content.pm.PackageManager; //导入方法依赖的package包/类
private boolean isFrameworkPackage(PackageManager packageManager, String packageName) {
    if (fakeFramework) {
        try {
            PackageInfo packageInfo = packageManager.getPackageInfo(packageName, 0);
            return isFrameworkPackage(packageManager, packageInfo);
        } catch (PackageManager.NameNotFoundException e) {
            UILog.w("cannot find " + packageName, e);
            return false;
        }
    } else {
        return packageManager.checkSignatures(PACKAGE_FRAMEWORK, packageName) ==
                PackageManager.SIGNATURE_MATCH;
    }
}
 
开发者ID:brevent,项目名称:Brevent,代码行数:15,代码来源:BreventActivity.java

示例8: getAppName

import android.content.pm.PackageManager; //导入方法依赖的package包/类
public static String getAppName(Context context) {
    String appName = "";
    try {
        PackageManager manager = context.getPackageManager();
        PackageInfo info = null;
        info = manager.getPackageInfo(context.getPackageName(), 0);
        appName = info.applicationInfo.loadLabel(manager).toString();
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }
    return appName;
}
 
开发者ID:lennyup,项目名称:react-native-udesk,代码行数:13,代码来源:UdeskUtil.java

示例9: loadPackageName

import android.content.pm.PackageManager; //导入方法依赖的package包/类
private CharSequence loadPackageName(String pkg) {
    try {
        ApplicationInfo info = mPm.getApplicationInfo(pkg,
                PackageManager.GET_UNINSTALLED_PACKAGES);
        if (info != null) return mPm.getApplicationLabel(info);
    } catch (PackageManager.NameNotFoundException e) {
        Log.e(TAG, "Cannot load package name", e);
    }
    return pkg;
}
 
开发者ID:ric96,项目名称:lineagex86,代码行数:11,代码来源:NotificationStation.java

示例10: getPermissionGroupInfo

import android.content.pm.PackageManager; //导入方法依赖的package包/类
private PermissionGroupInfo getPermissionGroupInfo(PackageManager packageManager, String group) {
    if (TextUtils.isEmpty(group)) {
        return null;
    }
    try {
        return packageManager.getPermissionGroupInfo(group, 0);
    } catch (PackageManager.NameNotFoundException e) {
        UILog.w("Can't find permission group " + group, e);
        return null;
    }
}
 
开发者ID:brevent,项目名称:Brevent,代码行数:12,代码来源:OpsItemAdapter.java

示例11: getAvailableIconPacks

import android.content.pm.PackageManager; //导入方法依赖的package包/类
public HashMap<String, IconPack> getAvailableIconPacks(boolean forceReload)
{
    if (iconPacks == null || forceReload)
    {
        iconPacks = new HashMap<String, IconPack>();

        // find apps with intent-filter "com.gau.go.launcherex.theme" and return build the HashMap
        PackageManager pm = mContext.getPackageManager();

        List<ResolveInfo> adwlauncherthemes = pm.queryIntentActivities(new Intent("org.adw.launcher.THEMES"), PackageManager.GET_META_DATA);
        List<ResolveInfo> golauncherthemes = pm.queryIntentActivities(new Intent("com.gau.go.launcherex.theme"), PackageManager.GET_META_DATA);

        // merge those lists
        List<ResolveInfo> rinfo = new ArrayList<ResolveInfo>(adwlauncherthemes);
        rinfo.addAll(golauncherthemes);

        for(ResolveInfo ri  : rinfo)
        {
            IconPack ip = new IconPack();
            ip.packageName = ri.activityInfo.packageName;

            ApplicationInfo ai = null;
            try
            {
                ai = pm.getApplicationInfo(ip.packageName, PackageManager.GET_META_DATA);
                ip.name  = mContext.getPackageManager().getApplicationLabel(ai).toString();
                iconPacks.put(ip.packageName, ip);
            }
            catch (PackageManager.NameNotFoundException e)
            {
                // shouldn't happen
                e.printStackTrace();
            }
        }
    }
    return iconPacks;
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:38,代码来源:IconPackManager.java

示例12: getMetaDaApplication

import android.content.pm.PackageManager; //导入方法依赖的package包/类
/**
 * Read the meta-data information under the application tag
 *
 * @param context context
 * @return Bundle information for metaData under application tag [Bundle]
 */
public static Bundle getMetaDaApplication(Context context) {
    try {
        ApplicationInfo applicationInfo = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA);
        return applicationInfo.metaData;
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }
    return null;
}
 
开发者ID:Jusenr,项目名称:androidtools,代码行数:16,代码来源:AppUtils.java

示例13: isSystemApp

import android.content.pm.PackageManager; //导入方法依赖的package包/类
/**
 * 判断App是否是系统应用
 *
 * @param context     上下文
 * @param packageName 包名
 * @return {@code true}: 是<br>{@code false}: 否
 */
public static boolean isSystemApp(Context context, String packageName) {
    if (DataUtil.isNullString(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:ChunweiDu,项目名称:Utils,代码行数:20,代码来源:AppUtil.java

示例14: isLinkInstalled

import android.content.pm.PackageManager; //导入方法依赖的package包/类
@Override
public boolean isLinkInstalled(Context context, String packageName) {
    PackageInfo packageInfo;
    try {
        packageInfo = context.getPackageManager().getPackageInfo(packageName, 0);
    } catch (PackageManager.NameNotFoundException e) {
        packageInfo = null;
        e.printStackTrace();
    }
    if (packageInfo == null) {
        return false;
    } else {
        return true;
    }
}
 
开发者ID:bingo-oss,项目名称:linkopensdk-android,代码行数:16,代码来源:LinkApiImplV3.java

示例15: isPackageInstalled

import android.content.pm.PackageManager; //导入方法依赖的package包/类
/**
 * 是否安装了该包名的app
 *
 * @param context context
 * @param pkgName 包名
 * @return 是否安装
 */
private static boolean isPackageInstalled(Context context, String pkgName) {
    PackageManager pm = context.getPackageManager();
    try {
        PackageInfo pkgInfo = pm.getPackageInfo(pkgName, 0);
        return pkgInfo != null && pkgInfo.applicationInfo.enabled;
    } catch (PackageManager.NameNotFoundException e) {
    }
    return false;
}
 
开发者ID:yangjie127,项目名称:ESSocialSDK-master,代码行数:17,代码来源:SocialUtils.java


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