android.content.Context.getApplicationInfo()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(7.5k)|赞(0)|评价(0)|浏览(495)

本文整理了Java中android.content.Context.getApplicationInfo()方法的一些代码示例,展示了Context.getApplicationInfo()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Context.getApplicationInfo()方法的具体详情如下:
包路径:android.content.Context
类名称:Context
方法名:getApplicationInfo

Context.getApplicationInfo介绍

暂无

代码示例

代码示例来源:origin: stackoverflow.com

public DatePickerDialog(Context context,
  OnDateSetListener callBack,
  int year,
  int monthOfYear,
  int dayOfMonth,
  boolean yearOptional) {
    this(context, context.getApplicationInfo().targetSdkVersion >= Build.VERSION_CODES.HONEYCOMB
        ? com.android.internal.R.style.Theme_Holo_Light_Dialog_Alert
        : com.android.internal.R.style.Theme_Dialog_Alert,
    callBack, year, monthOfYear, dayOfMonth, yearOptional);
}

代码示例来源:origin: nostra13/Android-Universal-Image-Loader

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private static boolean isLargeHeap(Context context) {
  return (context.getApplicationInfo().flags & ApplicationInfo.FLAG_LARGE_HEAP) != 0;
}

代码示例来源:origin: Tencent/tinker

public static File getPatchTempDirectory(Context context) {
  ApplicationInfo applicationInfo = context.getApplicationInfo();
  if (applicationInfo == null) {
    // Looks like running on a test Context, so just return without patching.
    return null;
  }
  return new File(applicationInfo.dataDir, ShareConstants.PATCH_TEMP_DIRECTORY_NAME);
}

代码示例来源:origin: Tencent/tinker

/**
 * data dir, such as /data/data/tinker.sample.android/tinker
 * @param context
 * @return
 */
public static File getPatchDirectory(Context context) {
  ApplicationInfo applicationInfo = context.getApplicationInfo();
  if (applicationInfo == null) {
    // Looks like running on a test Context, so just return without patching.
    return null;
  }
  return new File(applicationInfo.dataDir, ShareConstants.PATCH_DIRECTORY_NAME);
}

代码示例来源:origin: commonsguy/cw-omnibus

static File getSharedPrefsDir(Context ctxt) {
 return(new File(new File(ctxt.getApplicationInfo().dataDir),
  "shared_prefs"));
}

代码示例来源:origin: facebook/stetho

/**
 * Execute command to print all keys and values stored in the shared preferences which match
 * the optional given prefix
 */
private void doPrint(PrintStream writer, List<String> args) {
 String rootPath = mAppContext.getApplicationInfo().dataDir + "/shared_prefs";
 String offsetPrefix = args.isEmpty() ? "" : args.get(0);
 String keyPrefix = (args.size() > 1) ? args.get(1) : "";
 printRecursive(writer, rootPath, "", offsetPrefix, keyPrefix);
}

代码示例来源:origin: facebook/stetho

private CharSequence getAppLabel() {
  PackageManager pm = mContext.getPackageManager();
  return pm.getApplicationLabel(mContext.getApplicationInfo());
 }
}

代码示例来源:origin: facebook/stetho

public static List<String> getSharedPreferenceTags(Context context) {
 ArrayList<String> tags = new ArrayList<String>();
 String rootPath = context.getApplicationInfo().dataDir + "/shared_prefs";
 File root = new File(rootPath);
 if (root.exists()) {
  for (File file : root.listFiles()) {
   String fileName = file.getName();
   if (fileName.endsWith(PREFS_SUFFIX)) {
    tags.add(fileName.substring(0, fileName.length() - PREFS_SUFFIX.length()));
   }
  }
 }
 Collections.sort(tags);
 return tags;
}

代码示例来源:origin: facebook/litho

private static boolean isLayoutDirectionRTL(Context context) {
 ApplicationInfo applicationInfo = context.getApplicationInfo();
 if ((SDK_INT >= JELLY_BEAN_MR1)
   && (applicationInfo.flags & ApplicationInfo.FLAG_SUPPORTS_RTL) != 0) {
  int layoutDirection = getLayoutDirection(context);
  return layoutDirection == View.LAYOUT_DIRECTION_RTL;
 }
 return false;
}

代码示例来源:origin: ACRA/acra

@NonNull
  @Override
  public File getFile(@NonNull Context context, @NonNull String fileName) {
    File dir;
    if (Build.VERSION.SDK_INT >= 21) {
      dir = context.getNoBackupFilesDir();
    } else {
      dir = new File(context.getApplicationInfo().dataDir, "no_backup");
    }
    return new File(dir, fileName);
  }
},

代码示例来源:origin: amitshekhariitbhu/Android-Debug-Database

public static List<String> getSharedPreferenceTags(Context context) {
  ArrayList<String> tags = new ArrayList<>();
  String rootPath = context.getApplicationInfo().dataDir + "/shared_prefs";
  File root = new File(rootPath);
  if (root.exists()) {
    for (File file : root.listFiles()) {
      String fileName = file.getName();
      if (fileName.endsWith(PREFS_SUFFIX)) {
        tags.add(fileName.substring(0, fileName.length() - PREFS_SUFFIX.length()));
      }
    }
  }
  Collections.sort(tags);
  return tags;
}

代码示例来源:origin: mcxiaoke/packer-ng-plugin

public static synchronized String getChannelOrThrow(final Context context)
    throws IOException {
  final ApplicationInfo info = context.getApplicationInfo();
  return PackerCommon.readChannel(new File(info.sourceDir));
}

代码示例来源:origin: stackoverflow.com

public String getAppLable(Context context) {
  PackageManager packageManager = context.getPackageManager();
  ApplicationInfo applicationInfo = null;
  try {
    applicationInfo = packageManager.getApplicationInfo(context.getApplicationInfo().packageName, 0);
  } catch (final NameNotFoundException e) {
  }
  return (String) (applicationInfo != null ? packageManager.getApplicationLabel(applicationInfo) : "Unknown");
}

代码示例来源:origin: yanzhenjie/NoHttp

protected String uniqueKey(String key) {
  key += mContext.getApplicationInfo().packageName;
  return Encryption.getMD5ForString(key);
}

代码示例来源:origin: Tencent/tinker

public static boolean isInMainProcess(Context context) {
  String mainProcessName = null;
  ApplicationInfo applicationInfo = context.getApplicationInfo();
  if (applicationInfo != null) {
    mainProcessName = applicationInfo.processName;
  }
  if (isNullOrNil(mainProcessName)) {
    mainProcessName = context.getPackageName();
  }
  String processName = getProcessName(context);
  if (processName == null || processName.length() == 0) {
    processName = "";
  }
  return mainProcessName.equals(processName);
}

代码示例来源:origin: yanzhenjie/NoHttp

public CacheEntityDao(Context context) {
  super(new CacheSQLHelper(context));
  String encryptionKey = context.getApplicationInfo().packageName;
  mEncryption = new Encryption(encryptionKey);
}

代码示例来源:origin: square/picasso

static int calculateMemoryCacheSize(Context context) {
 ActivityManager am = ContextCompat.getSystemService(context, ActivityManager.class);
 boolean largeHeap = (context.getApplicationInfo().flags & FLAG_LARGE_HEAP) != 0;
 int memoryClass = largeHeap ? am.getLargeMemoryClass() : am.getMemoryClass();
 // Target ~15% of the available heap.
 return (int) (1024L * 1024L * memoryClass / 7);
}

代码示例来源:origin: robolectric/robolectric

@Test
@Config(minSdk = Build.VERSION_CODES.N)
public void setUpApplicationState_shouldCreateStorageDirs_Nplus() throws Exception {
 bootstrapWrapper.callSetUpApplicationState();
 ApplicationInfo applicationInfo = ApplicationProvider.getApplicationContext()
   .getApplicationInfo();
 assertThat(applicationInfo.credentialProtectedDataDir).isNotNull();
 assertThat(new File(applicationInfo.credentialProtectedDataDir).isDirectory()).isTrue();
 assertThat(applicationInfo.deviceProtectedDataDir).isNotNull();
 assertThat(new File(applicationInfo.deviceProtectedDataDir).isDirectory()).isTrue();
}

代码示例来源:origin: robolectric/robolectric

@Test
public void setUpApplicationState_shouldCreateStorageDirs() throws Exception {
 bootstrapWrapper.callSetUpApplicationState();
 ApplicationInfo applicationInfo = ApplicationProvider.getApplicationContext()
   .getApplicationInfo();
 assertThat(applicationInfo.sourceDir).isNotNull();
 assertThat(new File(applicationInfo.sourceDir).exists()).isTrue();
 assertThat(applicationInfo.publicSourceDir).isNotNull();
 assertThat(new File(applicationInfo.publicSourceDir).exists()).isTrue();
 assertThat(applicationInfo.dataDir).isNotNull();
 assertThat(new File(applicationInfo.dataDir).isDirectory()).isTrue();
}

代码示例来源:origin: robolectric/robolectric

@Test
public void getXml() throws Exception {
 XmlResourceParser in =
   packageManager.getXml(
     ApplicationProvider.getApplicationContext().getPackageName(),
     R.xml.dialog_preferences,
     ApplicationProvider.getApplicationContext().getApplicationInfo());
 assertThat(in).isNotNull();
}

相关文章

Context类方法