本文整理汇总了Java中android.app.Application.getApplicationContext方法的典型用法代码示例。如果您正苦于以下问题:Java Application.getApplicationContext方法的具体用法?Java Application.getApplicationContext怎么用?Java Application.getApplicationContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.Application
的用法示例。
在下文中一共展示了Application.getApplicationContext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initLocation
import android.app.Application; //导入方法依赖的package包/类
/**
* Initializes the {@link LocationEngine} based on whether or not
* simulation is enabled.
*/
@SuppressWarnings({"MissingPermission"})
private void initLocation(Application application) {
if (!shouldSimulateRoute) {
modelLocationEngine = new LostLocationEngine(application.getApplicationContext());
modelLocationEngine.setPriority(LocationEnginePriority.HIGH_ACCURACY);
modelLocationEngine.setFastestInterval(1000);
modelLocationEngine.setInterval(0);
this.locationEngine.setValue(modelLocationEngine);
if (modelLocationEngine.getLastLocation() != null) {
onLocationChanged(modelLocationEngine.getLastLocation());
}
} else {
// Fire a null location update to fetch the route if we are launching with coordinates
onLocationChanged(null);
}
}
示例2: init
import android.app.Application; //导入方法依赖的package包/类
/**
* 初始化库
*
* @param isDebug 是否打印日志
* @param TAG 日志TAG
* @param context application
*/
public static void init(@NonNull boolean isDebug, @NonNull String TAG, @NonNull Application context) {
android.util.Log.d(TAG_, "==============您使用的KUtils版本:2.4.2==============");
if (TAG == null || context == null) throw new RuntimeException("KUtilLibs 初始化参数均不能为空");
appContext = context.getApplicationContext();
if (isDebug) Log.init(TAG, true);//开启日志打印
DialogUIUtils.init(appContext);
OkGo.getInstance().init(context);
}
示例3: install
import android.app.Application; //导入方法依赖的package包/类
public static void install(Application application) {
mContext = application.getApplicationContext();
Fresco.initialize(mContext);
LogUtils.allowLog = !BuildConfig.DEBUG;
XLog.init(BuildConfig.DEBUG ? LogLevel.ALL : LogLevel.NONE);
SpUtil.init(mContext);
if (LeakCanary.isInAnalyzerProcess(mContext)) {
return;
}
LeakCanary.install(application);
}
示例4: providePluginConfig
import android.app.Application; //导入方法依赖的package包/类
@Provides
PluginConfig providePluginConfig(@IoExecutor Executor ioExecutor,
AndroidExecutor androidExecutor, SecureRandom random,
SocketFactory torSocketFactory, BackoffFactory backoffFactory,
Application app, LocationUtils locationUtils, DevReporter reporter,
EventBus eventBus) {
Context appContext = app.getApplicationContext();
DuplexPluginFactory bluetooth = new DroidtoothPluginFactory(ioExecutor,
androidExecutor, appContext, random, backoffFactory);
DuplexPluginFactory tor = new TorPluginFactory(ioExecutor, appContext,
locationUtils, reporter, eventBus, torSocketFactory,
backoffFactory);
DuplexPluginFactory lan = new AndroidLanTcpPluginFactory(ioExecutor,
backoffFactory, appContext);
final Collection<DuplexPluginFactory> duplex =
Arrays.asList(bluetooth, tor, lan);
@NotNullByDefault
PluginConfig pluginConfig = new PluginConfig() {
@Override
public Collection<DuplexPluginFactory> getDuplexFactories() {
return duplex;
}
@Override
public Collection<SimplexPluginFactory> getSimplexFactories() {
return Collections.emptyList();
}
};
return pluginConfig;
}
示例5: start
import android.app.Application; //导入方法依赖的package包/类
/**
* Inicia uma instancia da lib PlainRequest
*
* @param app
*/
public void start(Application app) {
if(context == null) {
context = app.getApplicationContext();
queue = Volley.newRequestQueue(context); // Criação do RequestQueue
}
}
示例6: init
import android.app.Application; //导入方法依赖的package包/类
/**
* 初始化工具类
*/
public static void init(@NonNull Application app) {
if (isDebug()) {
ARouter.openLog();
ARouter.openDebug();
}
ARouter.init(app);
Fresco.initialize(app.getApplicationContext());
ZKBase.context = app.getApplicationContext();
}
示例7: AndroidNotificationManagerImpl
import android.app.Application; //导入方法依赖的package包/类
@Inject
AndroidNotificationManagerImpl(@DatabaseExecutor Executor dbExecutor,
SettingsManager settingsManager, AndroidExecutor androidExecutor,
Application app) {
this.dbExecutor = dbExecutor;
this.settingsManager = settingsManager;
this.androidExecutor = androidExecutor;
appContext = app.getApplicationContext();
}
示例8: init
import android.app.Application; //导入方法依赖的package包/类
/**
* 初始化
* @param application
* @param isApplyImmediate 是否立刻生效
*/
public void init(Application application, boolean isApplyImmediate) {
if (application == null)
return;
isInited = true;
mContext = application.getApplicationContext();
mAndroidSkinManager = new AndroidSkinManager(application.getApplicationContext());
if (isApplyImmediate)
mAndroidSkinManager.loadSkinIfApply();
AndroidSkinHook.getInstance().registerActivityLife(application);
}
示例9: provideApplicationContext
import android.app.Application; //导入方法依赖的package包/类
@Provides @Singleton @ApplicationContext Context provideApplicationContext(
Application application) {
return application.getApplicationContext();
}
示例10: LoginViewModel
import android.app.Application; //导入方法依赖的package包/类
public LoginViewModel(Application context) {
super(context);
mContext = context.getApplicationContext();
}
示例11: AndroidLocationUtils
import android.app.Application; //导入方法依赖的package包/类
@Inject
AndroidLocationUtils(Application app) {
appContext = app.getApplicationContext();
}
示例12: AndroidSecureRandomProvider
import android.app.Application; //导入方法依赖的package包/类
@Inject
AndroidSecureRandomProvider(Application app) {
appContext = app.getApplicationContext();
}
示例13: EnvironmentalSensorsViewModel
import android.app.Application; //导入方法依赖的package包/类
@Inject
public EnvironmentalSensorsViewModel(Application context, EnvironmentalSensorsRepository environmentalSensorsRepository) {
super(context);
this.mContext = context.getApplicationContext();
this.mEnvironmentalSensorsRepository = environmentalSensorsRepository;
}
示例14: init
import android.app.Application; //导入方法依赖的package包/类
public static void init(Application application, OkHttpClient.Builder builder){
context = application.getApplicationContext();
if(builder!=null){
okHttpClient = builder.build();
}
}
示例15: AppModule
import android.app.Application; //导入方法依赖的package包/类
public AppModule(Application application) {
this.context = application.getApplicationContext();
}