当前位置: 首页>>代码示例>>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;未经允许,请勿转载。