Example usage for android.content Context getPackageName

List of usage examples for android.content Context getPackageName

Introduction

In this page you can find the example usage for android.content Context getPackageName.

Prototype

public abstract String getPackageName();

Source Link

Document

Return the name of this application's package.

Usage

From source file:Main.java

public static String getVerName(Context context) {
    String verName = "";
    try {/*from   ww w  . j  a v  a 2  s .  c  o m*/
        String packageName = context.getPackageName();
        verName = context.getPackageManager().getPackageInfo(packageName, 0).versionName;
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }
    return verName;
}

From source file:Main.java

/**
 * Launches the Play Store product page for calling app
 *
 * @param context//from   www .  jav a  2s .  co  m
 */
public static void launchPlayStoreProductPage(Context context) {
    launchPlayStoreProductPage(context, context.getPackageName());
}

From source file:Main.java

public static boolean alwaysPlay2DefaultRender(Context context) {
    boolean flag;
    try {/* w w  w  .  j  ava  2 s . c om*/
        flag = context.getSharedPreferences(context.getPackageName(), 1).getBoolean("alway_play_to", false);
    } catch (Exception exception) {
        return false;
    }
    return flag;
}

From source file:Main.java

public static int getThemeIdentifier(Context context, String name, String type) {
    return context.getResources().getIdentifier(name, type, context.getPackageName());
}

From source file:Main.java

/**
 * @param emojiUnicode/*  w w w  . ja v  a  2 s. com*/
 * @param c
 * @return
 */
public static Integer getEmoticonResId(String emojiUnicode, Context c) {
    return c.getResources().getIdentifier("emoji_" + emojiUnicode, "drawable", c.getPackageName());
}

From source file:Main.java

public static String getPackageName(Context ctx) {
    try {//from  w ww .  j av  a  2 s . co m
        PackageInfo info = ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), 0);
        return info.packageName;
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
        return null;
    }
}

From source file:Main.java

public static int intIDFromResource(Context context, String name, String type) {
    return context.getResources().getIdentifier(name, type, context.getPackageName());
}

From source file:Main.java

public static String getVersionName(Context ctx) {
    try {/*from   w w  w.  j  a  v a 2 s .co m*/
        PackageInfo packInfo = ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), 0);
        return packInfo.versionName;
    } catch (Throwable t) {
        throw new RuntimeException(t);
    }
}

From source file:Main.java

/**
 * get version name.//from  w ww.  ja  v a2  s  .  co  m
 */
public static String getVerName(Context context) {
    String verName = "";
    try {
        String packageName = context.getPackageName();
        verName = context.getPackageManager().getPackageInfo(packageName, 0).versionName;
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }
    return verName;
}

From source file:Main.java

public static Integer getVersionCode(Context context) {
    try {/*w  ww .  j av  a2  s .co m*/
        PackageInfo pi = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
        return pi.versionCode;
    } catch (NameNotFoundException e) {
        return null;
    }
}