List of usage examples for android.content Context getPackageName
public abstract String getPackageName();
From source file:Main.java
public static int getResourcesIdByName(Context context, String name, String defType) { return context.getResources().getIdentifier(name, defType, context.getPackageName()); }
From source file:Main.java
private static PackageInfo getPackageInfo(Context context) throws NameNotFoundException { return context.getPackageManager().getPackageInfo(context.getPackageName(), 0); }
From source file:Main.java
public static PackageInfo getPackageInfo(Context context) { try {/*from w w w .ja va2 s . c o m*/ return context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_CONFIGURATIONS); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } return null; }
From source file:Main.java
private static int getUid(Context context) { try {/* w w w .j a v a2 s . c o m*/ int uid = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA).uid; return uid; } catch (Exception e) { } return 0; }
From source file:Main.java
private static int getId(Context ctx, String type, String name) { return ctx.getResources().getIdentifier(name, type, ctx.getPackageName()); }
From source file:Main.java
public static int getId(Context paramContext, String paramString) { return paramContext.getResources().getIdentifier(paramString, "id", paramContext.getPackageName()); }
From source file:Main.java
public static String getVersion(Context context) { try {/* w w w .j a va2s . c om*/ PackageInfo pi = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); return pi.versionName; } catch (NameNotFoundException e) { e.printStackTrace(); return ""; } }
From source file:Main.java
public static Uri getUriForRawId(@NonNull Context context, @RawRes int rawId) { return Uri.parse("android.resource://" + context.getPackageName() + "/" + rawId); }
From source file:Main.java
public static int getImageId(Context context, String imageName) { return context.getResources().getIdentifier("drawable/" + imageName, null, context.getPackageName()); }
From source file:Main.java
public static int getVersionCode(Context context) { try {//w w w. j av a 2s . c om PackageInfo pi = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); return pi.versionCode; } catch (PackageManager.NameNotFoundException e) { return 0; } }