List of usage examples for android.content Context getPackageName
public abstract String getPackageName();
From source file:Main.java
public static int getAppVersionCode(Context context) { PackageInfo info = null;/*w w w . ja v a2s.com*/ try { info = context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_ACTIVITIES); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } return info.versionCode; }
From source file:Main.java
public static String getAppVersionName(Context context) { PackageInfo info = null;//from ww w .j a v a 2s. c o m try { info = context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_ACTIVITIES); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } return info.versionName; }
From source file:Main.java
public static PackageInfo getApplicationInfo(Context context) { PackageInfo info = null;//from w ww . j a v a 2 s .c o m try { info = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } return info; }
From source file:Main.java
public static int getVersionCode(Context context) { int versionCode = 0; try {/* www. j a v a 2 s . co m*/ versionCode = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode; } catch (NameNotFoundException e) { e.printStackTrace(); } return versionCode; }
From source file:Main.java
private static String getSDKServerFolder(Context ctx) { if (ctx == null) { return null; }// w ww . java 2 s . com String packageName = ctx.getPackageName(); if (packageName == null || packageName.length() <= 0) { return null; } File serverFolder = new File("/data/data/" + packageName + "/ECSDK_Msg"); if (!serverFolder.exists() && !serverFolder.mkdirs()) { return null; } return serverFolder.getAbsolutePath(); }
From source file:Main.java
public static String getAppVersionCode(Context context) { int versionCode = 0; try {/*from w ww . j av a 2s .c o m*/ versionCode = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode; } catch (NameNotFoundException e) { e.printStackTrace(); } return String.valueOf(versionCode); }
From source file:Main.java
public static boolean isDebuggable(Context context) { PackageManager pacMan = context.getPackageManager(); String pacName = context.getPackageName(); ApplicationInfo appInfo = null;/*from w w w . j a v a2 s.co m*/ try { appInfo = pacMan.getApplicationInfo(pacName, 0); } catch (NameNotFoundException e) { e.printStackTrace(); } if (appInfo != null) { if ((appInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) { return true; } else { return false; } } else { return false; } }
From source file:Main.java
public static String getMetaData(Context context, String key) { try {/*from w w w .j a va 2s .co m*/ ApplicationInfo info = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA); String values = info.metaData.getString(key); return values; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } return null; }
From source file:Main.java
public static boolean checkFirstStart(Context paramContext) { SharedPreferences time = paramContext .getSharedPreferences("collection_agent_" + paramContext.getPackageName(), 0); int flag = time.getInt("flag", 0); if (flag == 0) { return true; }/*w w w .ja v a 2 s . c o m*/ return false; }
From source file:Main.java
public static int getVersionCode(Context context) { int versionCode = 1; try {//from w ww . j a v a2 s .c om versionCode = context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode; } catch (NameNotFoundException e) { e.printStackTrace(); } return versionCode; }