Utils

 
	public static DisplayMetrics getMetrics(Activity context) {
		DisplayMetrics metrics = new DisplayMetrics();
		context.getWindowManager().getDefaultDisplay().getMetrics(metrics);
		return metrics;
	}

	/**
	 * 
	 * @param context
	 * @return PackageInfo
	 */
	public static PackageInfo getPackageInfo(Activity context) {
		String packageName = context.getPackageName();
		try {
			PackageInfo packageInfo = context.getPackageManager()
					.getPackageInfo(
							packageName,
							PackageManager.GET_CONFIGURATIONS
									| PackageManager.GET_ACTIVITIES);
			return packageInfo;
		} catch (NameNotFoundException e) {
			e.printStackTrace();
			return null;
		}
	}

你可能感兴趣的:(Utils)