当前位置: 首页>>代码示例>>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;未经允许,请勿转载。