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


Java NameNotFoundException.printStackTrace方法代码示例

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


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

示例1: getAppVersionCode

import android.content.pm.PackageManager.NameNotFoundException; //导入方法依赖的package包/类
public static int getAppVersionCode(Context context) {
    if (context != null) {
        PackageManager pm = context.getPackageManager();
        if (pm != null) {
            PackageInfo pi;
            try {
                pi = pm.getPackageInfo(context.getPackageName(), 0);
                if (pi != null) {
                    return pi.versionCode;
                }
            } catch (NameNotFoundException e) {
                e.printStackTrace();
            }
        }
    }
    return -1;
}
 
开发者ID:wzx54321,项目名称:XinFramework,代码行数:18,代码来源:PackageUtil.java

示例2: getRegistrationId

import android.content.pm.PackageManager.NameNotFoundException; //导入方法依赖的package包/类
private String getRegistrationId(Context context) {
    final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
    String registrationId = prefs.getString(PROPERTY_REG_ID, "");
    if (registrationId=="") {
        Log.i(TAG, "GCM Registration not found in prefs.");
        return "";
    }
    // Check if app was updated; if so, it must clear the registration ID
    // since the existing regID is not guaranteed to work with the new
    // app version.
    String registeredVersion = prefs.getString(FlowzrSyncOptions.PROPERTY_APP_VERSION, "");
    String currentVersion;
	try {
		currentVersion = getApplicationContext().getPackageManager().getPackageInfo(getApplicationContext().getPackageName(), 0).versionName;
	    if (!registeredVersion.equals(currentVersion)) {
	        Log.i(TAG, "App version changed.");
	        return "";
	    }
	} catch (NameNotFoundException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
    return registrationId;
}
 
开发者ID:tiberiusteng,项目名称:financisto1-holo,代码行数:25,代码来源:FlowzrSyncActivity.java

示例3: getMetaData

import android.content.pm.PackageManager.NameNotFoundException; //导入方法依赖的package包/类
public static String getMetaData(Context context, @NonNull String key) {
    String metaDataValue = "";
    try {
        PackageManager packageManager = context.getPackageManager();
        if (packageManager != null) {
            ApplicationInfo applicationInfo = packageManager.getApplicationInfo(
                    context.getPackageName(), PackageManager.GET_META_DATA);
            if (applicationInfo != null && applicationInfo.metaData != null) {
                metaDataValue = applicationInfo.metaData.getString(key);
            }
        }
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }

    return metaDataValue;
}
 
开发者ID:jiajieshen,项目名称:AndroidDevSamples,代码行数:18,代码来源:ApplicationUtil.java

示例4: getAppName

import android.content.pm.PackageManager.NameNotFoundException; //导入方法依赖的package包/类
/**
 * 获得APP的名称
 *
 * @param context
 * @return
 */
public static String getAppName(Context context) {
    if (context == null) {
        return null;
    }
    try {
        PackageManager packageManager = context.getPackageManager();
        PackageInfo packageInfo = packageManager.getPackageInfo(
                context.getPackageName(), 0);
        int labelRes = packageInfo.applicationInfo.labelRes;
        String appName = context.getResources().getString(labelRes);
        return appName;
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }
    return null;
}
 
开发者ID:TIIEHenry,项目名称:TIIEHenry-Android-SDK,代码行数:23,代码来源:AppUtils.java

示例5: getPackageInfo

import android.content.pm.PackageManager.NameNotFoundException; //导入方法依赖的package包/类
/**
 * 获取指定程序信息
 */
public static android.content.pm.PackageInfo getPackageInfo(Context context, String pkg) {
    try {
        return context.getPackageManager().getPackageInfo(pkg, 0);
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }
    return null;
}
 
开发者ID:lanyuanxiaoyao,项目名称:PicKing,代码行数:12,代码来源:PackageUtil.java

示例6: getPackageInfo

import android.content.pm.PackageManager.NameNotFoundException; //导入方法依赖的package包/类
/**
 * 获取指定程序信息
 */
public static PackageInfo getPackageInfo(Context context, String pkg) {
    try {
        return context.getPackageManager().getPackageInfo(pkg, 0);
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }
    return null;
}
 
开发者ID:wzx54321,项目名称:XinFramework,代码行数:12,代码来源:PackageUtil.java

示例7: getChannel

import android.content.pm.PackageManager.NameNotFoundException; //导入方法依赖的package包/类
public static String getChannel(Context context , String channelKey) {
	String msg = null;
	try {
		ApplicationInfo appInfo = context.getPackageManager() .getApplicationInfo(context.getPackageName(),
				PackageManager.GET_META_DATA);
		msg=appInfo.metaData.getString(channelKey);
	} catch (NameNotFoundException e) {
		e.printStackTrace();
	}
	return msg;
}
 
开发者ID:ebridfighter,项目名称:GongXianSheng,代码行数:12,代码来源:CommonUtils.java

示例8: onCreate

import android.content.pm.PackageManager.NameNotFoundException; //导入方法依赖的package包/类
@Override
public void onCreate() {
    super.onCreate();
    try {
        mPackageInfo = getPackageManager().getPackageInfo(
                getPackageName(), 0);
        ApplicationInfo ai = getApplicationInfo();
        CharSequence applicationLabel = getPackageManager().getApplicationLabel(ai);
        mNotification = new DownloadNotification(this, applicationLabel);

    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }
}
 
开发者ID:snoozinsquatch,项目名称:unity-obb-downloader,代码行数:15,代码来源:DownloaderService.java

示例9: initWithApiKey

import android.content.pm.PackageManager.NameNotFoundException; //导入方法依赖的package包/类
private void initWithApiKey(Context context) {
    try {
        ApplicationInfo appInfo = context.getPackageManager().getApplicationInfo(context
                .getPackageName(), 128);
        Object leyu_app_id = appInfo.metaData.get("leyu_app_id");
        Object leyu_app_key = appInfo.metaData.get("leyu_app_key");
        _app_id = String.valueOf(leyu_app_id);
        _app_key = String.valueOf(leyu_app_key);
    } catch (NameNotFoundException e) {
        e.printStackTrace();
        this._callback.onFailed(e.getMessage());
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:14,代码来源:LEYUApplication.java

示例10: getAppVersionName

import android.content.pm.PackageManager.NameNotFoundException; //导入方法依赖的package包/类
public static String getAppVersionName(Context context) {
    String version = "0";
    try {
        version = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }
    return version;
}
 
开发者ID:jeasinlee,项目名称:AndroidBasicLibs,代码行数:10,代码来源:SystemUtils.java

示例11: getText

import android.content.pm.PackageManager.NameNotFoundException; //导入方法依赖的package包/类
@Override
public String getText() {
    if (mName == null) {
        try {
            PackageManager pm = mContext.getPackageManager();
            PackageInfo pi = pm.getPackageInfo(mPackage, 0);
            mName = (String) pi.applicationInfo.loadLabel(pm);
        } catch (NameNotFoundException e) {
            e.printStackTrace();
            mName = mPackage;
        }
    }
    return mName; 
}
 
开发者ID:WrBug,项目名称:GravityBox,代码行数:15,代码来源:OngoingNotifPreference.java

示例12: getVersionCode

import android.content.pm.PackageManager.NameNotFoundException; //导入方法依赖的package包/类
/**
 * 获取APP版本号
 *
 * @param context
 * @return
 */
public static int getVersionCode(Context context) {
    int verCode = -1;
    try {
        verCode = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode;
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }
    return verCode;
}
 
开发者ID:xiarunhao123,项目名称:Ency,代码行数:16,代码来源:AppApplicationUtil.java

示例13: loadVersionInfo

import android.content.pm.PackageManager.NameNotFoundException; //导入方法依赖的package包/类
private static final void loadVersionInfo(Context context) {
	try {
		PackageInfo pi = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
		if (pi != null) {
			versionCode = pi.versionCode;
			versionName = pi.versionName;
		}
	} catch (NameNotFoundException e) {
		e.printStackTrace();
	}
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:12,代码来源:InstallUtil.java

示例14: isSystemApplication

import android.content.pm.PackageManager.NameNotFoundException; //导入方法依赖的package包/类
/**
 * whether packageName is system application
 *
 * @param packageManager
 * @param packageName
 * @return <ul>
 * <li>if packageManager is null, return false</li>
 * <li>if package name is null or is empty, return false</li>
 * <li>if package name not exit, return false</li>
 * <li>if package name exit, but not system app, return false</li>
 * <li>else return true</li>
 * </ul>
 */
public static boolean isSystemApplication(PackageManager packageManager, String packageName) {
    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 (NameNotFoundException e) {
        e.printStackTrace();
    }
    return false;
}
 
开发者ID:lizhangqu,项目名称:CorePatch,代码行数:27,代码来源:PackageUtils.java

示例15: getClientVersionName

import android.content.pm.PackageManager.NameNotFoundException; //导入方法依赖的package包/类
public static String getClientVersionName(Context context) {
    if (context == null) {
        return "";
    }
    try {
        return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName;
    } catch (NameNotFoundException e) {
        e.printStackTrace();
        return "";
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:12,代码来源:DataUtils.java


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