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