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

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

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

Context.getApplicationContext介绍

暂无

代码示例

代码示例来源:origin: bumptech/glide

@SuppressWarnings("WeakerAccess")
public MediaStoreImageThumbLoader(Context context) {
 this.context = context.getApplicationContext();
}

代码示例来源:origin: bumptech/glide

@SuppressWarnings("WeakerAccess")
public MediaStoreVideoThumbLoader(Context context) {
 this.context = context.getApplicationContext();
}

代码示例来源:origin: airbnb/lottie-android

NetworkCache(Context appContext, String url) {
 this.appContext = appContext.getApplicationContext();
 this.url = url;
}

代码示例来源:origin: bumptech/glide

public ResourceDrawableDecoder(Context context) {
 this.context = context.getApplicationContext();
}

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

public BaseImageDownloader(Context context, int connectTimeout, int readTimeout) {
  this.context = context.getApplicationContext();
  this.connectTimeout = connectTimeout;
  this.readTimeout = readTimeout;
}

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

public static void setEnabledAsync(Context context, final Class<?> componentClass,
  final boolean enabled) {
 final Context appContext = context.getApplicationContext();
 AsyncTask.THREAD_POOL_EXECUTOR.execute(new Runnable() {
  @Override public void run() {
   setEnabledBlocking(appContext, componentClass, enabled);
  }
 });
}

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

MySingleton.getInstance(Context c) {
  //
  // ... needing to create ...
  sInstance = new MySingleton(c.getApplicationContext());
}

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

AndroidRefWatcherBuilder(@NonNull Context context) {
 this.context = context.getApplicationContext();
}

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

public DefaultLeakDirectoryProvider(@NonNull Context context, int maxStoredHeapDumps) {
 if (maxStoredHeapDumps < 1) {
  throw new IllegalArgumentException("maxStoredHeapDumps must be at least 1");
 }
 this.context = context.getApplicationContext();
 this.maxStoredHeapDumps = maxStoredHeapDumps;
}

代码示例来源:origin: bumptech/glide

DefaultConnectivityMonitor(@NonNull Context context, @NonNull ConnectivityListener listener) {
 this.context = context.getApplicationContext();
 this.listener = listener;
}

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

static File createDefaultCacheDir(Context context) {
 File cache = new File(context.getApplicationContext().getCacheDir(), PICASSO_CACHE);
 if (!cache.exists()) {
  //noinspection ResultOfMethodCallIgnored
  cache.mkdirs();
 }
 return cache;
}

代码示例来源:origin: airbnb/lottie-android

private NetworkFetcher(Context context, String url) {
 appContext = context.getApplicationContext();
 this.url = url;
 networkCache = new NetworkCache(appContext, url);
}

代码示例来源:origin: bumptech/glide

private Api(Context context) {
 this.requestQueue = Volley.newRequestQueue(context.getApplicationContext());
 QueryListener queryListener = new QueryListener() {
  @Override
  public void onSearchCompleted(Query query, List<Photo> photos) {
   lastQueryResult = new QueryResult(query, photos);
  }
  @Override
  public void onSearchFailed(Query query, Exception e) {
   lastQueryResult = null;
  }
 };
 queryListeners.add(queryListener);
}

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

/** Start building a new {@link Picasso} instance. */
public Builder(@NonNull Context context) {
 checkNotNull(context, "context == null");
 this.context = context.getApplicationContext();
}

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

public static void install(@NonNull Context context, @NonNull RefWatcher refWatcher) {
 Application application = (Application) context.getApplicationContext();
 ActivityRefWatcher activityRefWatcher = new ActivityRefWatcher(application, refWatcher);
 application.registerActivityLifecycleCallbacks(activityRefWatcher.lifecycleCallbacks);
}

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

public ServiceHeapDumpListener(@NonNull final Context context,
  @NonNull final Class<? extends AbstractAnalysisResultService> listenerServiceClass) {
 this.listenerServiceClass = checkNotNull(listenerServiceClass, "listenerServiceClass");
 this.context = checkNotNull(context, "context").getApplicationContext();
}

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

@UiThread
@Trace
void showToast() {
  Toast.makeText(getContext().getApplicationContext(), "Hello World!", Toast.LENGTH_LONG).show();
}

代码示例来源:origin: bumptech/glide

@VisibleForTesting
ByteBufferGifDecoder(
  Context context,
  List<ImageHeaderParser> parsers,
  BitmapPool bitmapPool,
  ArrayPool arrayPool,
  GifHeaderParserPool parserPool,
  GifDecoderFactory gifDecoderFactory) {
 this.context = context.getApplicationContext();
 this.parsers = parsers;
 this.gifDecoderFactory = gifDecoderFactory;
 this.provider = new GifBitmapProvider(bitmapPool, arrayPool);
 this.parserPool = parserPool;
}

代码示例来源:origin: airbnb/lottie-android

/**
 * Parse an animation from raw/res. This is recommended over putting your animation in assets because
 * it uses a hard reference to R.
 * The resource id will be used as a cache key so future usages won't parse the json again.
 */
public static LottieTask<LottieComposition> fromRawRes(Context context, @RawRes final int rawRes) {
 // Prevent accidentally leaking an Activity.
 final Context appContext = context.getApplicationContext();
 return cache(rawResCacheKey(rawRes), new Callable<LottieResult<LottieComposition>>() {
  @Override public LottieResult<LottieComposition> call() {
   return fromRawResSync(appContext, rawRes);
  }
 });
}

代码示例来源:origin: bumptech/glide

@VisibleForTesting
public static synchronized void tearDown() {
 if (glide != null) {
  glide.getContext()
    .getApplicationContext()
    .unregisterComponentCallbacks(glide);
  glide.engine.shutdown();
 }
 glide = null;
}

相关文章

微信公众号

最新文章

更多

Context类方法