Context.getApplicationInfo
Code IndexAdd Codota to your IDE (free)

Best Java code snippets using android.content.Context.getApplicationInfo (Showing top 20 results out of 2,079)

  • Common ways to obtain Context
private void myMethod () {
Context c =
  • InstrumentationRegistry.getTargetContext()
  • View view;view.getContext()
  • ViewGroup parent;parent.getContext()
  • Smart code suggestions by Codota
}
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();
}
android.contentContextgetApplicationInfo

Popular methods of Context

  • getPackageName
  • getResources
  • getSystemService
  • obtainStyledAttributes
  • getApplicationContext
  • getString
  • getPackageManager
  • startActivity
  • getContentResolver
  • getSharedPreferences
  • getAssets
  • getTheme
  • getAssets,
  • getTheme,
  • getCacheDir,
  • startService,
  • sendBroadcast,
  • getFilesDir,
  • registerReceiver,
  • unregisterReceiver,
  • getExternalCacheDir

Popular in Java

  • Creating JSON documents from java classes using gson
  • setRequestProperty (URLConnection)
  • notifyDataSetChanged (ArrayAdapter)
  • getApplicationContext (Context)
  • MessageFormat (java.text)
    Produces concatenated messages in language-neutral way. New code should probably use java.util.Forma
  • Deque (java.util)
    A linear collection that supports element insertion and removal at both ends. The name deque is shor
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • BasicDataSource (org.apache.commons.dbcp)
    Basic implementation of javax.sql.DataSource that is configured via JavaBeans properties. This is no

For IntelliJ IDEA,
Android Studio or Eclipse

  • Search for JavaScript code betaCodota IntelliJ IDEA pluginCodota Android Studio pluginCode IndexSign in
  • EnterpriseFAQAboutBlogContact Us
  • Plugin user guideTerms of usePrivacy policyCodeboxFind Usages
Add Codota to your IDE (free)