本文整理匯總了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();
}