本文整理汇总了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.");
}
示例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;
}
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例14: assumeMaterial
import android.content.Context; //导入方法依赖的package包/类
private static boolean assumeMaterial(Context context) {
return context.getApplicationInfo().targetSdkVersion >= 21 && VERSION.SDK_INT >= 21;
}
示例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;
}