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:com.vinexs.tool.Utility.java

public static int getThemeResId(Context context) {
    try {//  w w w .  ja v  a  2 s  .  c  om
        return context.getApplicationInfo().theme;
    } catch (Exception e) {
        Log.e("Package", "Fail to get default theme", e);
        return 0;
    }
}

From source file:io.digibyte.tools.util.Utils.java

public static boolean isEmulatorOrDebug(Context app) {
    String fing = Build.FINGERPRINT;
    boolean isEmulator = false;
    if (fing != null) {
        isEmulator = fing.contains("vbox") || fing.contains("generic");
    }//from   w ww .  j  a v  a 2s .c  o  m
    return isEmulator || (0 != (app.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE));
}

From source file:com.google.android.gms.common.GooglePlayServicesUtilLight.java

public static String zzap(Context context) {
    Object obj = context.getApplicationInfo().name;
    if (!TextUtils.isEmpty(obj)) {
        return obj;
    }// www  .jav a 2  s  .c  om
    ApplicationInfo applicationInfo;
    String packageName = context.getPackageName();
    PackageManager packageManager = context.getApplicationContext().getPackageManager();
    try {
        applicationInfo = packageManager.getApplicationInfo(context.getPackageName(), 0);
    } catch (NameNotFoundException e) {
        applicationInfo = null;
    }
    return applicationInfo != null ? packageManager.getApplicationLabel(applicationInfo).toString()
            : packageName;
}

From source file:org.restcomm.app.utillib.Utils.Global.java

public static String getAppName(Context context) {
    String appname = "";
    try {//  w w  w.  j a v a  2 s.com
        PackageManager packageManager = context.getApplicationContext().getPackageManager();
        ApplicationInfo applicationInfo = context.getApplicationInfo();
        String name = (String) ((applicationInfo != null) ? packageManager.getApplicationLabel(applicationInfo)
                : context.getPackageName());

        appname = name;
    } catch (Exception e) {
    }
    return appname;
}

From source file:Main.java

public static Uri getHelpUrl(Context context, String fromWhere) {
    if (TextUtils.isEmpty(fromWhere)) {
        throw new IllegalArgumentException("getHelpUrl(): fromWhere must be non-empty");
    }/*from  w  w w  .  jav  a  2  s .c om*/
    Uri.Builder uri = Uri.parse("http://support.google.com/mobile").buildUpon();
    uri.appendQueryParameter("p", fromWhere);
    try {
        uri.appendQueryParameter("version", String.valueOf(context.getPackageManager()
                .getPackageInfo(((PackageItemInfo) context.getApplicationInfo()).packageName, 0).versionCode));
        return uri.build();
    } catch (PackageManager.NameNotFoundException e) {
        Log.e("Dialer",
                "Error finding package " + ((PackageItemInfo) context.getApplicationInfo()).packageName);
        return uri.build();
    }
}

From source file:org.pixmob.feedme.net.NetworkClient.java

/**
 * Generate an Http User-Agent.// ww  w. ja  v  a2 s  .c  o m
 */
private static final String generateUserAgent(Context context) {
    String applicationVersion = null;
    try {
        applicationVersion = context.getPackageManager().getPackageInfo(context.getPackageName(),
                0).versionName;
    } catch (NameNotFoundException e) {
        applicationVersion = "0.0.0";
    }
    return context.getApplicationInfo().name + "/" + applicationVersion + " (" + Build.MANUFACTURER + " "
            + Build.MODEL + " with Android " + Build.VERSION.RELEASE + "/" + Build.VERSION.SDK_INT + ")";
}

From source file:com.google.ipc.invalidation.ticl.android.AndroidChannel.java

/**
 * Returns the default HTTP client to use for requests from the channel based upon its execution
 * context.  The format of the User-Agent string is "<application-pkg>(<android-release>)".
 *//*w w w . jav  a 2 s  .c  o  m*/
static AndroidHttpClient getDefaultHttpClient(Context context) {
    return AndroidHttpClient
            .newInstance(context.getApplicationInfo().className + "(" + Build.VERSION.RELEASE + ")");
}

From source file:ru.appsm.inapphelp.IAHHelpDesk.java

private static int getApplicationIcon(Context context) {
    int appIconResId = 0;

    appIconResId = getIconValue(context.getPackageName(), "ic_notify");

    if (appIconResId == -1)
        appIconResId = context.getApplicationInfo().icon;

    return appIconResId;
}

From source file:com.example.gangzhang.myapplication.VideoPlayerActivity.java

public static String getDataDir(Context ctx) {
    ApplicationInfo ai = ctx.getApplicationInfo();

    if (ai.dataDir != null)
        return fixLastSlash(ai.dataDir);
    else/*  w  w w . j  a  v a 2s . c o  m*/
        return "/data/data/" + ai.packageName + "/";
}

From source file:me.gpelaez.cordova.plugins.ibeacon.GPIBeacon.java

private static String getAppName(Context context) {
    CharSequence appName = context.getPackageManager().getApplicationLabel(context.getApplicationInfo());

    return (String) appName;
}