當前位置: 首頁>>代碼示例>>Java>>正文


Java Activity.getResources方法代碼示例

本文整理匯總了Java中android.app.Activity.getResources方法的典型用法代碼示例。如果您正苦於以下問題:Java Activity.getResources方法的具體用法?Java Activity.getResources怎麽用?Java Activity.getResources使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.app.Activity的用法示例。


在下文中一共展示了Activity.getResources方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getLabel

import android.app.Activity; //導入方法依賴的package包/類
/**
 * 獲取 activity 的 label 屬性
 */
private static String getLabel(Activity activity, ActivityInfo ai) {
    String label;
    Resources res = activity.getResources();

    // 獲取 Activity label(如有)
    label = getLabelById(res, ai.labelRes);

    // 獲取插件 Application Label(如有)
    if (TextUtils.isEmpty(label)) {
        label = getLabelById(res, ai.applicationInfo.labelRes);
    }

    // 獲取宿主 App label
    if (TextUtils.isEmpty(label)) {
        Context appContext = RePluginInternal.getAppContext();
        Resources appResource = appContext.getResources();
        ApplicationInfo appInfo = appContext.getApplicationInfo();
        label = getLabelById(appResource, appInfo.labelRes);
    }

    if (LOG) {
        LogDebug.d(TAG, "label = " + label);
    }
    return label;
}
 
開發者ID:wangyupeng1-iri,項目名稱:springreplugin,代碼行數:29,代碼來源:ActivityInjector.java

示例2: getStatusBarHeight

import android.app.Activity; //導入方法依賴的package包/類
/**
 * 獲取頂部status bar 高度
 */
public static int getStatusBarHeight(Activity mActivity) {
    Resources resources = mActivity.getResources();
    int resourceId = resources.getIdentifier("status_bar_height", "dimen", "android");
    int height = resources.getDimensionPixelSize(resourceId);
    Log.i("height","Status height:" + height);
    return height;
}
 
開發者ID:haihaio,項目名稱:AmenWeather,代碼行數:11,代碼來源:Util.java

示例3: getNavigationBarHeight

import android.app.Activity; //導入方法依賴的package包/類
/**
 * 獲取NavigationBar的高度
 *
 * @param activity activity
 * @return NavigationBar高度
 */
public static int getNavigationBarHeight(Activity activity) {
    Resources resources = activity.getResources();
    int rid = resources.getIdentifier("config_showNavigationBar", "bool", "android");
    if (rid > 0) Log.v(TAG, "導航欄是否顯示?" + resources.getBoolean(rid));
    int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android");
    if (resourceId > 0) return resources.getDimensionPixelSize(resourceId);
    return 0;
}
 
開發者ID:shenhuanet,項目名稱:OpenEyesReading-android,代碼行數:15,代碼來源:MeasureUtils.java

示例4: downloadImageUrl

import android.app.Activity; //導入方法依賴的package包/類
private void downloadImageUrl(final Activity activity, final String imageUrl) {
    final SimpleTarget<Bitmap> target = new SimpleTarget<Bitmap>() {

        @Override
        public void onResourceReady(Bitmap bitmap, Transition<? super Bitmap> transition) {
            mUserImage = new BitmapDrawable(activity.getResources(), bitmap);
            mFacebookLoginResultCallBack.onFacebookLoginSuccess(mLoginResult);
        }

        @Override
        public void onLoadFailed(@Nullable Drawable errorDrawable) {
            super.onLoadFailed(errorDrawable);
            mFacebookLoginResultCallBack.onFacebookLoginImageDownloadFailed();
        }
    };

    new Handler(Looper.getMainLooper()).post(new Runnable() {
        @Override
        public void run() {
            RequestOptions options = new RequestOptions()
                    .placeholder(R.mipmap.ic_launcher_round);
            Glide.with(activity.getApplicationContext())
                    .asBitmap()
                    .apply(options)
                    .load(imageUrl)
                    .into(target);
        }
    });
}
 
開發者ID:davideas,項目名稱:AndroidBlueprints,代碼行數:30,代碼來源:FacebookHelper.java

示例5: setBarTheme

import android.app.Activity; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
private static void setBarTheme(Activity activity, int theme) {
	Button menuButton = (Button)activity.findViewById(R.id.menuButton);
	Button searchButton = (Button)activity.findViewById(R.id.searchButton);
	Button webSearchButton = (Button)activity.findViewById(R.id.webSearchButton);
	EditText searchField = (EditText)activity.findViewById(R.id.textField);
	Resources resources = activity.getResources();
	switch (theme) {
		case DEFAULT_THEME:
		case LIGHT:
		case WALLPAPER_LIGHT:
			if (Build.VERSION.SDK_INT >= 16) {
				menuButton.setBackground(resources.getDrawable(R.drawable.menu_bg));
				searchButton.setBackground(resources.getDrawable(R.drawable.search_bg));
				webSearchButton.setBackground(resources.getDrawable(R.drawable.web_search_bg));
			} else {
				menuButton.setBackgroundDrawable(resources.getDrawable(R.drawable.menu_bg));
				searchButton.setBackgroundDrawable(resources.getDrawable(R.drawable.search_bg));
				webSearchButton.setBackgroundDrawable(resources.getDrawable(R.drawable.web_search_bg));
			}
			searchField.setTextColor(Color.WHITE);
			break;
		default:
			if (Build.VERSION.SDK_INT >= 16) {
				menuButton.setBackground(resources.getDrawable(R.drawable.menu_dark_bg));
				searchButton.setBackground(resources.getDrawable(R.drawable.search_dark_bg));
				webSearchButton.setBackground(resources.getDrawable(R.drawable.web_search_dark_bg));
			} else {
				menuButton.setBackgroundDrawable(resources.getDrawable(R.drawable.menu_dark_bg));
				searchButton.setBackgroundDrawable(resources.getDrawable(R.drawable.search_dark_bg));
				webSearchButton.setBackgroundDrawable(resources.getDrawable(R.drawable.web_search_dark_bg));
			}
			searchField.setTextColor(Color.BLACK);
	}
}
 
開發者ID:HenriDellal,項目名稱:emerald,代碼行數:36,代碼來源:Themer.java

示例6: SystemBarConfig

import android.app.Activity; //導入方法依賴的package包/類
private SystemBarConfig(Activity activity, boolean translucentStatusBar, boolean traslucentNavBar) {
    Resources res = activity.getResources();
    mInPortrait = (res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT);
    mSmallestWidthDp = getSmallestWidthDp(activity);
    mStatusBarHeight = getInternalDimensionSize(res, STATUS_BAR_HEIGHT_RES_NAME);
    mActionBarHeight = getActionBarHeight(activity);
    mNavigationBarHeight = getNavigationBarHeight(activity);
    mNavigationBarWidth = getNavigationBarWidth(activity);
    mHasNavigationBar = (mNavigationBarHeight > 0);
    mTranslucentStatusBar = translucentStatusBar;
    mTranslucentNavBar = traslucentNavBar;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:13,代碼來源:SystemBarTintManager.java

示例7: StopOnLastElement

import android.app.Activity; //導入方法依賴的package包/類
public  void StopOnLastElement(Bitmap bitmap[], Activity activity, int IdOfView, final int Duration)
{
    LAST_FLAG_VALUE=bitmap.length;
    view=activity.findViewById(IdOfView);
    drawable=new Drawable[bitmap.length];
    for (int i=0;i<bitmap.length;i++)
    {
        drawable[i]=new BitmapDrawable(activity.getResources(),bitmap[i]);
    }
    StopOnLastElementExecute(drawable,Duration);
}
 
開發者ID:Dwijraj,項目名稱:FriskyImage,代碼行數:12,代碼來源:FriskyFade.java

示例8: getMessageForEnablingOsGlobalPermission

import android.app.Activity; //導入方法依賴的package包/類
@Override
protected String getMessageForEnablingOsGlobalPermission(Activity activity) {
    Resources resources = activity.getResources();
    if (enabledForChrome(activity)) {
        return resources.getString(R.string.android_location_off_globally);
    }
    return resources.getString(R.string.android_location_also_off_globally);
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:9,代碼來源:LocationCategory.java

示例9: ActivityConfig

import android.app.Activity; //導入方法依賴的package包/類
public ActivityConfig(@NonNull Activity activity) {
    Resources res = activity.getResources();
    mInPortrait = (res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT);
    mSmallestWidthDp = getSmallestWidthDp(activity);
    mNavigationBarHeight = getNavigationBarHeight(activity);
    mNavigationBarWidth = getNavigationBarWidth(activity);
    mHasNavigationBar = mNavigationBarHeight > 0;
}
 
開發者ID:ls1110924,項目名稱:ImmerseMode,代碼行數:9,代碼來源:ActivityConfig.java

示例10: BarConfig

import android.app.Activity; //導入方法依賴的package包/類
public BarConfig(Activity activity) {
    Resources res = activity.getResources();
    mInPortrait = (res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT);
    mSmallestWidthDp = getSmallestWidthDp(activity);
    mStatusBarHeight = getInternalDimensionSize(res, STATUS_BAR_HEIGHT_RES_NAME);
    mActionBarHeight = getActionBarHeight(activity);
    mNavigationBarHeight = getNavigationBarHeight(activity);
    mNavigationBarWidth = getNavigationBarWidth(activity);
    mHasNavigationBar = (mNavigationBarHeight > 0);
}
 
開發者ID:penghongru,項目名稱:Coder,代碼行數:11,代碼來源:BarConfig.java

示例11: SystemBarConfig

import android.app.Activity; //導入方法依賴的package包/類
private SystemBarConfig(Activity activity, boolean translucentStatusBar,
    boolean traslucentNavBar) {
  Resources res = activity.getResources();
  mInPortrait = (res.getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT);
  mSmallestWidthDp = getSmallestWidthDp(activity);
  mStatusBarHeight = getInternalDimensionSize(res, STATUS_BAR_HEIGHT_RES_NAME);
  mActionBarHeight = getActionBarHeight(activity);
  mNavigationBarHeight = getNavigationBarHeight(activity);
  mNavigationBarWidth = getNavigationBarWidth(activity);
  mHasNavigationBar = (mNavigationBarHeight > 0);
  mTranslucentStatusBar = translucentStatusBar;
  mTranslucentNavBar = traslucentNavBar;
}
 
開發者ID:Lingzh0ng,項目名稱:BrotherWeather,代碼行數:14,代碼來源:SystemBarTintManager.java

示例12: AppAdapter

import android.app.Activity; //導入方法依賴的package包/類
public AppAdapter(Activity activity, RecyclerView recyclerView) {
    super(activity, recyclerView);
    mResources = activity.getResources();
    mMatrix = new ColorMatrix();
    mMatrix.setSaturation(0); // 參數大於1將增加飽和度,0~1之間會減少飽和度。0值將產生一幅灰度圖像。
    mColorFilterGrey = new ColorMatrixColorFilter(mMatrix);
    mMatrix.setSaturation(1); // 參數大於1將增加飽和度,0~1之間會減少飽和度。0值將產生一幅灰度圖像。
    mColorFilterNormal = new ColorMatrixColorFilter(mMatrix);
    mMatrix.setSaturation(0.2f); // 參數大於1將增加飽和度,0~1之間會減少飽和度。0值將產生一幅灰度圖像。
    mColorFilter50 = new ColorMatrixColorFilter(mMatrix);
}
 
開發者ID:XYScience,項目名稱:StopApp,代碼行數:12,代碼來源:AppAdapter.java

示例13: hasNavBar

import android.app.Activity; //導入方法依賴的package包/類
public static boolean hasNavBar(Activity activity) {
  Resources resources = activity.getResources();
  int id = resources.getIdentifier("config_showNavigationBar", "bool", "android");
  if (id > 0) {
    return resources.getBoolean(id);
  } else {    // Check for keys
    boolean hasMenuKey = ViewConfiguration.get(activity).hasPermanentMenuKey();
    boolean hasBackKey = KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_BACK);
    return !hasMenuKey && !hasBackKey;
  }
}
 
開發者ID:Arjun-sna,項目名稱:Android-AudioRecorder-App,代碼行數:12,代碼來源:ViewUtil.java

示例14: ValidateActivityResource

import android.app.Activity; //導入方法依賴的package包/類
private boolean ValidateActivityResource(Activity activity){
String exceptionString = null;
String bundleName = AtlasBundleInfoManager.instance().getBundleForComponet(activity.getLocalClassName());
BundleImpl b = (BundleImpl)Framework.getBundle(bundleName);
String bundlePath = null;
if (b != null){
	bundlePath = b.getArchive().getArchiveFile().getAbsolutePath();
}

Resources resource = null;
if (AtlasHacks.ContextThemeWrapper_mResources != null){
	resource = AtlasHacks.ContextThemeWrapper_mResources.get(activity);
} else {
	resource = activity.getResources();
}
Resources resource_runtime = RuntimeVariables.delegateResources;
if (resource == resource_runtime){
	return true;
}
List<String> paths = getAssetPathFromResources(resource);
String pathsOfHis = DelegateResources.getCurrentAssetpathStr(RuntimeVariables.androidApplication.getAssets());
List<String> pathsRuntime = getAssetPathFromResources(resource_runtime);		
if ((bundlePath != null) && (paths != null) && !paths.contains(bundlePath)){
	exceptionString += "(1.1) Activity Resources path not contains:" + b.getArchive().getArchiveFile().getAbsolutePath();
	if (!pathsOfHis.contains(bundlePath)){
		exceptionString += "(1.2) paths in history not contains:" + b.getArchive().getArchiveFile().getAbsolutePath();
	}
	if (!pathsRuntime.contains(bundlePath)){
		exceptionString += "(1.3) paths in runtime not contains:" + b.getArchive().getArchiveFile().getAbsolutePath();
	}
	if (b.getArchive().getArchiveFile().exists() == false){
		exceptionString += "(1.4) Bundle archive file not exist:" + b.getArchive().getArchiveFile().getAbsolutePath();
	}
	exceptionString += "(1.5) Activity Resources paths length:" + paths.size();
}

if (exceptionString != null){
	return false;
}

return true;
  }
 
開發者ID:alibaba,項目名稱:atlas,代碼行數:43,代碼來源:InstrumentationHook.java

示例15: HandleResourceNotFound

import android.app.Activity; //導入方法依賴的package包/類
private void HandleResourceNotFound(Activity activity, Bundle icicle, Exception e) {
	if(activity!=null && !ErrorActivityRecords.contains(activity.getClass().getName())){
		//fix #8224429
		ErrorActivityRecords.add(activity.getClass().getName());
		try {
			activity.finish();
		}catch(Throwable e2){}
		return;
	}
	String exceptionString = null;
	try{
		Resources resource = null;
		if (AtlasHacks.ContextThemeWrapper_mResources != null){
			resource = AtlasHacks.ContextThemeWrapper_mResources.get(activity);
		} else {
			resource = activity.getResources();
		}
		List<String> paths = getAssetPathFromResources(resource);
		List<String> pathsRuntime = getAssetPathFromResources(RuntimeVariables.delegateResources);
		String pathsOfHis = DelegateResources.getCurrentAssetpathStr(resource.getAssets());
		String bundleName = AtlasBundleInfoManager.instance().getBundleForComponet(activity.getLocalClassName());
		BundleImpl b = (BundleImpl)Framework.getBundle(bundleName);
		exceptionString += "Paths: " + paths;
		if (b != null){
			String bundlePath = b.getArchive().getArchiveFile().getAbsolutePath();
			if (!paths.contains(bundlePath)){
				exceptionString += "(2.1) Activity Resources path not contains:" + b.getArchive().getArchiveFile().getAbsolutePath();
			}
			if (!pathsRuntime.contains(bundlePath)){
				exceptionString += "(2.2) Activity Resources path not contains:" + b.getArchive().getArchiveFile().getAbsolutePath();
			}
			if (!pathsOfHis.contains(bundlePath)){
				exceptionString += "(2.3) paths in history not contains:" + b.getArchive().getArchiveFile().getAbsolutePath();
			}
			if (b.getArchive().getArchiveFile().exists() == false){
				exceptionString += "(2.4) Bundle archive file not exist:" + b.getArchive().getArchiveFile().getAbsolutePath();
			}
			if (FileUtils.CheckFileValidation(b.getArchive().getArchiveFile().getAbsolutePath())){
				exceptionString += "(2.5) Bundle archive file can not opened with stream:" + b.getArchive().getArchiveFile().getAbsolutePath();
			}
		}
		if (resource == RuntimeVariables.delegateResources){
			exceptionString += "(2.6) DelegateResources equals Activity Resources";
		}
		exceptionString += "(2.7) Activity Resources paths length:" + paths.size();
	} catch (Exception e1){
		String pathsInRunTime = " " +  DelegateResources.getCurrentAssetpathStr(RuntimeVariables.androidApplication.getAssets());
		exceptionString = "(2.8) paths in history:" + pathsInRunTime  + " getAssetPath fail: " + e1;
	}
	throw new RuntimeException( exceptionString, e);

}
 
開發者ID:alibaba,項目名稱:atlas,代碼行數:53,代碼來源:InstrumentationHook.java


注:本文中的android.app.Activity.getResources方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。