Example usage for android.content Context getApplicationInfo

List of usage examples for android.content Context getApplicationInfo

Introduction

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

Prototype

public abstract ApplicationInfo getApplicationInfo();

Source Link

Document

Return the full application info for this context's package.

Usage

From source file:Main.java

public static boolean isDebugVersion(Context ctx) {
    int flags = ctx.getApplicationInfo().flags;
    if ((flags &= ApplicationInfo.FLAG_DEBUGGABLE) != 0) {

        return true;
    } else {/*from   w  ww.  ja  v  a 2s  . c o m*/
        return false;
    }
}

From source file:Main.java

public static String getApplicationName(Context context) {
    ApplicationInfo applicationInfo = context.getApplicationInfo();
    int stringId = applicationInfo.labelRes;
    return stringId == 0 ? applicationInfo.nonLocalizedLabel.toString() : context.getString(stringId);
}

From source file:Main.java

public static boolean readFromPrefsBoolean(Context ctx, String key) {
    return ctx.getSharedPreferences(ctx.getApplicationInfo().packageName, ctx.MODE_PRIVATE).getBoolean(key,
            false);/* w  w w.  j av  a 2s. co m*/
}

From source file:Main.java

public static String getAppName(Context context) {
    ApplicationInfo applicationInfo = context.getApplicationInfo();
    PackageManager packageManager = context.getPackageManager();
    String appName = packageManager.getApplicationLabel(applicationInfo).toString();
    return appName;
}

From source file:Main.java

public static boolean isDebuggable(Context ctx) {
    ApplicationInfo appInfo = ctx.getApplicationInfo();
    boolean debug = (appInfo.flags & FLAG_DEBUGGABLE) != 0;
    return debug;
}

From source file:Main.java

/**
 * Reading from Preferences/*  ww w. j a v  a  2  s .  c om*/
 */

public static String readFromPrefsString(Context ctx, String key) {
    return ctx.getSharedPreferences(ctx.getApplicationInfo().packageName, ctx.MODE_PRIVATE).getString(key, "");
}

From source file:Main.java

public static String getEncodingLibraryPath(Context paramContext) {
    return new StringBuilder(String.valueOf(paramContext.getApplicationInfo().nativeLibraryDir))
            .append("/libencoding.so").toString();
}

From source file:Main.java

public static void setIsDeBug(Context context) {
    ApplicationInfo applicationInfo = context.getApplicationInfo();
    try {//from w  w w .j a v a  2  s. c o  m
        isDebug = ((applicationInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0);
    } catch (Exception e) {
        isDebug = false;
        e.printStackTrace();
    }
}

From source file:Main.java

public static String getAppName(Context context) {
    try {/* ww  w  . j  a  v a2 s . co  m*/
        return context.getString(context.getApplicationInfo().labelRes);
    } catch (Resources.NotFoundException e) {
        return "";
    }
}

From source file:Main.java

public static void debugMode(Context context) {
    if (isDebug == null) {
        isDebug = context.getApplicationInfo() != null
                && (context.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
    }/*from   w w w  . ja v a  2s.c o m*/
}