本文整理汇总了Java中android.app.Application.getResources方法的典型用法代码示例。如果您正苦于以下问题:Java Application.getResources方法的具体用法?Java Application.getResources怎么用?Java Application.getResources使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.Application
的用法示例。
在下文中一共展示了Application.getResources方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import android.app.Application; //导入方法依赖的package包/类
/**
* Initializes Lex with custom delimiters. Must be called before any other Lex methods are invoked and should be called
* ONLY from {@link Application#onCreate()}.
* @param app
* @param openDelimiter
* @param closeDelimiter
*/
public static void init(@NonNull Application app, @NonNull String openDelimiter, @NonNull String closeDelimiter) {
if(Lex.resources != null) {
throw new LexAlreadyInitializedException();
}
Lex.resources = app.getResources();
LexContext.setDefaultDelimiters(openDelimiter, closeDelimiter);
}
示例2: estimateContentSize
import android.app.Application; //导入方法依赖的package包/类
/**
* Provides an estimate of the contents size.
*
* The estimate is likely to be incorrect. This is not a problem, as the aim
* is to avoid getting a different layout and resources than needed at
* render time.
* @param application The application to use for getting resources.
* @param convertToDp Whether the value should be converted to dp from pixels.
* @return The estimated prerender size in pixels or dp.
*/
public static Rect estimateContentSize(Application application, boolean convertToDp) {
// The size is estimated as:
// X = screenSizeX
// Y = screenSizeY - top bar - bottom bar - custom tabs bar
// The bounds rectangle includes the bottom bar and the custom tabs bar as well.
Rect screenBounds = new Rect();
Point screenSize = new Point();
WindowManager wm = (WindowManager) application.getSystemService(Context.WINDOW_SERVICE);
wm.getDefaultDisplay().getSize(screenSize);
Resources resources = application.getResources();
int statusBarId = resources.getIdentifier("status_bar_height", "dimen", "android");
try {
screenSize.y -= resources.getDimensionPixelSize(statusBarId);
} catch (Resources.NotFoundException e) {
// Nothing, this is just a best effort estimate.
}
screenBounds.set(0,
resources.getDimensionPixelSize(R.dimen.custom_tabs_control_container_height),
screenSize.x, screenSize.y);
if (convertToDp) {
float density = resources.getDisplayMetrics().density;
screenBounds.top = (int) Math.ceil(screenBounds.top / density);
screenBounds.left = (int) Math.ceil(screenBounds.left / density);
screenBounds.right = (int) Math.ceil(screenBounds.right / density);
screenBounds.bottom = (int) Math.ceil(screenBounds.bottom / density);
}
return screenBounds;
}
示例3: ChaosflixViewModel
import android.app.Application; //导入方法依赖的package包/类
public ChaosflixViewModel(Application application){
super(application);
Resources res = application.getResources();
String recordingUrl = res.getString(R.string.api_media_ccc_url);
String streamingUrl = res.getString(R.string.streaming_media_ccc_url);
OkHttpClient client = new OkHttpClient();
GsonConverterFactory gsonConverterFactory = GsonConverterFactory.create();
RxJava2CallAdapterFactory rxJava2CallAdapterFactory = RxJava2CallAdapterFactory.create();
Retrofit retrofitRecordings = new Retrofit.Builder()
.baseUrl(recordingUrl)
.client(client)
.addConverterFactory(gsonConverterFactory)
.addCallAdapterFactory(rxJava2CallAdapterFactory)
.build();
recordingApi = retrofitRecordings.create(RecordingService.class);
Retrofit retrofigStreaming = new Retrofit.Builder()
.baseUrl(streamingUrl)
.client(client)
.addConverterFactory(gsonConverterFactory)
.addCallAdapterFactory(rxJava2CallAdapterFactory)
.build();
streamingApi = retrofigStreaming.create(StreamingService.class);
database = Room.databaseBuilder(getApplication().getApplicationContext(), ChaosflixDatabase.class, "mediaccc.db").build();
}
示例4: TrackerManager
import android.app.Application; //导入方法依赖的package包/类
private TrackerManager(Application application, int analyticsConfigLocation) {
resources = application.getResources();
mGaConfigLocation = analyticsConfigLocation;
mTracker = getDefaultTracker(application);
}
示例5: init
import android.app.Application; //导入方法依赖的package包/类
/**
* Init the framework
*
* @param application
* @return
* @throws Exception
*/
public void init(Application application,boolean reset) throws AssertionArrayException, Exception {
if(application==null){
throw new RuntimeException("application is null");
}
ApplicationInfo app_info = application.getApplicationInfo();
sAPKSource = app_info.sourceDir;
boolean DEBUG = (app_info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
RuntimeVariables.androidApplication = application;
RuntimeVariables.delegateResources = application.getResources();
DelegateResources.walkroundActionMenuTextColor(RuntimeVariables.delegateResources);
Framework.containerVersion = RuntimeVariables.sInstalledVersionName;
ClassLoader cl = Atlas.class.getClassLoader();
Framework.systemClassLoader = cl;
// defineAndVerify
String packageName = application.getPackageName();
//
DelegateClassLoader newClassLoader = new DelegateClassLoader(cl);
// init RuntimeVariables
RuntimeVariables.delegateClassLoader = newClassLoader;
AndroidHack.injectClassLoader(packageName, newClassLoader);
AndroidHack.injectInstrumentationHook(new InstrumentationHook(AndroidHack.getInstrumentation(), application.getBaseContext()));
// add listeners
bundleLifecycleHandler = new BundleLifecycleHandler();
Framework.syncBundleListeners.add(bundleLifecycleHandler);
frameworkLifecycleHandler = new FrameworkLifecycleHandler();
Framework.frameworkListeners.add(frameworkLifecycleHandler);
try {
ActivityManagerDelegate activityManagerProxy = new ActivityManagerDelegate();
Object gDefault = null;
if(Build.VERSION.SDK_INT>25 || (Build.VERSION.SDK_INT==25&&Build.VERSION.PREVIEW_SDK_INT>0)){
gDefault=AtlasHacks.ActivityManager_IActivityManagerSingleton.get(AtlasHacks.ActivityManager.getmClass());
}else{
gDefault=AtlasHacks.ActivityManagerNative_gDefault.get(AtlasHacks.ActivityManagerNative.getmClass());
}
AtlasHacks.Singleton_mInstance.hijack(gDefault, activityManagerProxy);
}catch(Throwable e){}
AndroidHack.hackH();
}
示例6: resolver
import android.app.Application; //导入方法依赖的package包/类
@Provides
static StringResolver resolver(Application application) {
return new StringResolver(application.getResources());
}