List of usage examples for android.content Context getPackageName
public abstract String getPackageName();
From source file:Main.java
public static int getCurrentApkReleaseVersion(Context context) { try {// w w w. j av a 2s . c om return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode; } catch (PackageManager.NameNotFoundException e) { throw new AssertionError(e); } }
From source file:Main.java
public static int getResId(Context paramContext, String paramString) { return paramContext.getResources().getIdentifier(paramString, "id", paramContext.getPackageName()); }
From source file:Main.java
public static boolean isCorrectPasscode(Context context, String inputPasscode) { SharedPreferences prefs = context.getSharedPreferences(context.getPackageName(), Context.MODE_PRIVATE); if (prefs.getString(PREFS_KEY_PASSCODE, null).contentEquals(inputPasscode)) return true; else/*from w w w . java2 s . co m*/ return false; }
From source file:Main.java
public static int getApplicationVersion(Context context) { try {/*from w w w . j a va 2 s. c o m*/ PackageInfo info = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); return info.versionCode; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } return 1; }
From source file:Main.java
public static int getAppVersionCode(Context context) { try {//from w w w. java 2 s .com PackageInfo pi = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); return pi.versionCode; } catch (NameNotFoundException e) { e.printStackTrace(); return 0; } }
From source file:Main.java
public static int getAppVersion(Context context) { try {// w w w. j a v a 2 s . co m PackageInfo info = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); return info.versionCode; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } return 1; }
From source file:Main.java
public static int getRowId(Context paramContext, String paramString) { return paramContext.getResources().getIdentifier(paramString, "row", paramContext.getPackageName()); }
From source file:Main.java
public static PackageInfo getPackageInfo(Context context) { try {//from w ww.ja v a2s . c o m PackageInfo info = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); return info; } catch (NameNotFoundException e) { } return null; }
From source file:Main.java
public static int getVersionCode(Context context) { try {//from ww w. j av a2s. c om PackageInfo info = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); return info.versionCode; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } return 1; }
From source file:Main.java
/** * Returns the package name of the installer of the calling app * * @param context/* w w w .j av a 2 s . c om*/ * @return The package name of the installer */ public static String getInstallerPackageName(Context context) { return getInstallerPackageName(context, context.getPackageName()); }