當前位置: 首頁>>代碼示例>>Java>>正文


Java Context.getApplicationInfo方法代碼示例

本文整理匯總了Java中android.content.Context.getApplicationInfo方法的典型用法代碼示例。如果您正苦於以下問題:Java Context.getApplicationInfo方法的具體用法?Java Context.getApplicationInfo怎麽用?Java Context.getApplicationInfo使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.content.Context的用法示例。


在下文中一共展示了Context.getApplicationInfo方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: CondomCore

import android.content.Context; //導入方法依賴的package包/類
CondomCore(final Context base, final CondomOptions options, final String tag) {
	mBase = base;
	DEBUG = (base.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
	mExcludeBackgroundReceivers = options.mExcludeBackgroundReceivers;
	mExcludeBackgroundServices = SDK_INT < O && options.mExcludeBackgroundServices;
	mOutboundJudge = options.mOutboundJudge;
	mDryRun = options.mDryRun;

	mPackageManager = new Lazy<PackageManager>() { @Override protected PackageManager create() {
		return new CondomPackageManager(CondomCore.this, base.getPackageManager(), tag);
	}};
	mContentResolver = new Lazy<ContentResolver>() { @Override protected ContentResolver create() {
		return new CondomContentResolver(CondomCore.this, base, base.getContentResolver());
	}};

	final List<CondomKit> kits = options.mKits == null ? null : new ArrayList<>(options.mKits);
	if (kits != null && ! kits.isEmpty()) {
		mKitManager = new CondomKitManager();
		for (final CondomKit kit : kits)
			kit.onRegister(mKitManager);
	} else mKitManager = null;

	if (mDryRun) Log.w(tag, "Start dry-run mode, no outbound requests will be blocked actually, despite later stated in log.");
}
 
開發者ID:oasisfeng,項目名稱:condom,代碼行數:25,代碼來源:CondomCore.java

示例2: x

import android.content.Context; //導入方法依賴的package包/類
public static boolean x(Context context) {
    try {
        return (context.getApplicationInfo().flags & 2) != 0;
    } catch (Exception e) {
        return false;
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:8,代碼來源:bt.java

示例3: get

import android.content.Context; //導入方法依賴的package包/類
/**
 * Returns a unique instance of the ViewServer. This method should only be
 * called from the main thread of your application. The server will have
 * the same lifetime as your process.
 * 
 * If your application does not have the <code>android:debuggable</code>
 * flag set in its manifest, the server returned by this method will
 * be a dummy object that does not do anything. This allows you to use
 * the same code in debug and release versions of your application.
 * 
 * @param context A Context used to check whether the application is
 *                debuggable, this can be the application context
 */
public static ViewServer get(Context context) {
    ApplicationInfo info = context.getApplicationInfo();
    if (BUILD_TYPE_USER.equals(Build.TYPE) &&
            (info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0) {
        if (sServer == null) {
            sServer = new ViewServer(ViewServer.VIEW_SERVER_DEFAULT_PORT);
        }

        if (!sServer.isRunning()) {
            try {
                sServer.start();
            } catch (IOException e) {
                Log.d(LOG_TAG, "Error:", e);
            }
        }
    } else {
        sServer = new NoopViewServer();
    }

    return sServer;
}
 
開發者ID:rtr-nettest,項目名稱:open-rmbt,代碼行數:35,代碼來源:ViewServer.java

示例4: FunctionRunner

import android.content.Context; //導入方法依賴的package包/類
/**
 * Initialization; needs a context to find the classpath.
 * @param ctx
 */
public FunctionRunner(Context ctx) {
    /*
     * It would be nicer if we could just look at the classloaders for this class and
     * the one being run, but the details we need aren't publicly exposed there as far as
     * I can see. I'd rather do this than hack around with reflection or parsing classloaders'
     * toString().
     */
    ApplicationInfo appInfo = ctx.getApplicationInfo();
    mClassPath = appInfo.sourceDir + File.pathSeparator +
            TextUtils.join(File.pathSeparator, appInfo.splitSourceDirs);

    // and I guess there's really no better way for this either
    // TODO let caller optionally configure this?
    mCodeCacheDir = ctx.getCodeCacheDir().getPath();
}
 
開發者ID:scintill,項目名稱:android-runas,代碼行數:20,代碼來源:FunctionRunner.java

示例5: get2thDexSHA1

import android.content.Context; //導入方法依賴的package包/類
/**
 * 獲取dex2文件的SHA1-Digest值
 *
 * @param context
 * @return
 */
private String get2thDexSHA1(Context context) {
    ApplicationInfo info = context.getApplicationInfo();
    String source = info.sourceDir;
    try {
        JarFile jar = new JarFile(source);
        Manifest mf = jar.getManifest();
        Map<String, Attributes> map = mf.getEntries();
        Attributes a = map.get("classes2.dex");
        return a.getValue("SHA1-Digest");
    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}
 
開發者ID:ymqq,項目名稱:CommonFramework,代碼行數:21,代碼來源:BaseApplication.java

示例6: s

import android.content.Context; //導入方法依賴的package包/類
public static int[] s(Context context) {
    try {
        int a;
        int a2;
        int i;
        Object displayMetrics = new DisplayMetrics();
        ((WindowManager) context.getSystemService("window")).getDefaultDisplay().getMetrics(displayMetrics);
        if ((context.getApplicationInfo().flags & 8192) == 0) {
            a = a(displayMetrics, "noncompatWidthPixels");
            a2 = a(displayMetrics, "noncompatHeightPixels");
        } else {
            a2 = -1;
            a = -1;
        }
        if (a == -1 || a2 == -1) {
            i = displayMetrics.widthPixels;
            a = displayMetrics.heightPixels;
        } else {
            i = a;
            a = a2;
        }
        int[] iArr = new int[2];
        if (i > a) {
            iArr[0] = a;
            iArr[1] = i;
            return iArr;
        }
        iArr[0] = i;
        iArr[1] = a;
        return iArr;
    } catch (Throwable e) {
        bv.e(a, "read resolution fail", e);
        return null;
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:36,代碼來源:bt.java

示例7: isDebuggable

import android.content.Context; //導入方法依賴的package包/類
public static boolean isDebuggable(Context context) {
    try {
        return (context.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
    } catch (Exception e) {

    }
    return false;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:9,代碼來源:UpdateUtil.java

示例8: getApkPath

import android.content.Context; //導入方法依賴的package包/類
@Nullable
private static String getApkPath(@NonNull final Context context) {
    String apkPath = null;
    try {
        final ApplicationInfo applicationInfo = context.getApplicationInfo();
        if (applicationInfo == null) {
            return null;
        }
        apkPath = applicationInfo.sourceDir;
    } catch (Throwable e) {
    }
    return apkPath;
}
 
開發者ID:Meituan-Dianping,項目名稱:walle,代碼行數:14,代碼來源:WalleChannelReader.java

示例9: isAppPreinstalled

import android.content.Context; //導入方法依賴的package包/類
/**
 * this is true when its a system app or was preinstalled on the phone
 *
 * @param context
 * @return
 */
public static boolean isAppPreinstalled(Context context) {
    ApplicationInfo info = context.getApplicationInfo();
    if (info != null && info.flags != 0) {
        if ((info.flags & ApplicationInfo.FLAG_SYSTEM) == 1) {
            return true;
        }
    }
    return false;
}
 
開發者ID:Webtrekk,項目名稱:webtrekk-android-sdk,代碼行數:16,代碼來源:HelperFunctions.java

示例10: isDebug

import android.content.Context; //導入方法依賴的package包/類
private static boolean isDebug(Context context) {
    if (context == null) {
        return true;
    }
    ApplicationInfo info = context.getApplicationInfo();
    return (info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
}
 
開發者ID:zkwlx,項目名稱:DroidTelescope,代碼行數:8,代碼來源:BlockMonitorManager.java

示例11: readShowSetupWizardIcon

import android.content.Context; //導入方法依賴的package包/類
public static boolean readShowSetupWizardIcon(final SharedPreferences prefs,
        final Context context) {
    if (!prefs.contains(PREF_SHOW_SETUP_WIZARD_ICON)) {
        final ApplicationInfo appInfo = context.getApplicationInfo();
        final boolean isApplicationInSystemImage =
                (appInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
        // Default value
        return !isApplicationInSystemImage;
    }
    return prefs.getBoolean(PREF_SHOW_SETUP_WIZARD_ICON, false);
}
 
開發者ID:sergeychilingaryan,項目名稱:AOSP-Kayboard-7.1.2,代碼行數:12,代碼來源:Settings.java

示例12: isApkDebugable

import android.content.Context; //導入方法依賴的package包/類
public static boolean isApkDebugable(Context context) {
    try {
        ApplicationInfo info= context.getApplicationInfo();
        return (info.flags& ApplicationInfo.FLAG_DEBUGGABLE)== ApplicationInfo.FLAG_DEBUGGABLE;
    } catch (Exception e) {

    }
    return false;
}
 
開發者ID:l465659833,項目名稱:Bigbang,代碼行數:10,代碼來源:LogUtil.java

示例13: ArticlesDBHelper

import android.content.Context; //導入方法依賴的package包/類
/**
 * Constructor to manipulate with ready database
 *
 * @param context Context of application.
 */
public ArticlesDBHelper(Context context) {
    super(context, DATABASE_NAME, null, DATABASE_VERSION);
    if (android.os.Build.VERSION.SDK_INT >= 17) {
        DATABASE_PATH = context.getApplicationInfo().dataDir + "/databases/";
    } else {
        DATABASE_PATH = "/data/data/" + context.getPackageName() + "/databases/";
    }
    this.mContext = context;
}
 
開發者ID:white-collar,項目名稱:mobile-grammar,代碼行數:15,代碼來源:ArticlesDBHelper.java

示例14: assumeMaterial

import android.content.Context; //導入方法依賴的package包/類
private static boolean assumeMaterial(Context context) {
    return context.getApplicationInfo().targetSdkVersion >= 21 && VERSION.SDK_INT >= 21;
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:4,代碼來源:ActionBarDrawerToggle.java

示例15: getLayoutResId

import android.content.Context; //導入方法依賴的package包/類
/**
 * 獲取布局的ID
 */
public static int getLayoutResId(Context context, String name) {
    ApplicationInfo appInfo = context.getApplicationInfo();
    int resID = context.getResources().getIdentifier(name, "layout", appInfo.packageName);
    return resID;
}
 
開發者ID:littleRich,項目名稱:AutoInteraction-Library,代碼行數:9,代碼來源:Util.java


注:本文中的android.content.Context.getApplicationInfo方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。