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 isApkInDebug(Context context) {
    try {/*from  w w  w .j a  v  a 2  s. c o m*/
        ApplicationInfo info = context.getApplicationInfo();
        return (info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
    } catch (Exception e) {
        return false;
    }
}

From source file:Main.java

public static boolean isApkDebugable(Context context) {
    try {/*from  www . j  a v a 2  s.  c  o  m*/
        ApplicationInfo info = context.getApplicationInfo();
        return (info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
    } catch (Exception e) {

    }
    return false;
}

From source file:Main.java

public static boolean isApkDebug(Context context) {
    try {//from  w  ww.  j a  v a 2  s .c  o m
        ApplicationInfo info = context.getApplicationInfo();
        return (info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
    } catch (Exception e) {

    }
    return false;
}

From source file:Main.java

public static String getDefaultDatabaseName(Context context) {
    return DATABASE_START + context.getString(context.getApplicationInfo().labelRes) + DATABASE_TYPE;
}

From source file:Main.java

/**
 * Sync lib debug with app's debug value. Should be called in module Application.
 *
 * @param context/*  w w  w .  j a  va  2s  .  com*/
 */
public static void syncIsDebug(Context context) {
    if (isDebug == null) {
        isDebug = context.getApplicationInfo() != null
                && (context.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
    }
}

From source file:Main.java

/**
 * @return the name of the app (as defined in the "label" attribute in the manifest)
 *///w  w w.j  a  v  a  2s .  c o m
public static String getApplicationLabel(Context context) {
    ApplicationInfo appInfo = context.getApplicationInfo();
    return (String) context.getPackageManager().getApplicationLabel(appInfo);
}

From source file:Main.java

/**
 * Return the name of application//  w  w  w. ja  v a  2  s  .c  o m
 * @param context
 * @return
 */
public static String getApplicationName(Context context) {
    ApplicationInfo applicationInfo = context.getApplicationInfo();
    return context.getString(applicationInfo.labelRes);
}

From source file:Main.java

public static String getAppName(Context context) {
    if (context == null)
        return "";
    return context.getApplicationInfo().name;
}

From source file:Main.java

public static void removeOldVersionFiles(Context context, String fileName) {
    File dataDirPath = new File(context.getApplicationInfo().dataDir);
    File[] fileList = dataDirPath.listFiles();

    for (File file : fileList) {
        if (file.getAbsoluteFile().toString().endsWith(fileName)) {
            file.delete();/*from  w  w  w  . jav  a2  s. c om*/
        }
    }
}

From source file:Main.java

public static String getPackageName(Context context) {
    if (context == null)
        return "";
    return context.getApplicationInfo().packageName;

}