List of usage examples for android.app Activity getResources
@Override
public Resources getResources()
From source file:com.android.mail.utils.ViewUtils.java
/** * Sets the status bar color of the provided activity. *//* w w w .j a v a2s .c om*/ @SuppressLint("NewApi") public static void setStatusBarColor(Activity activity, @ColorRes int colorId) { if (Utils.isRunningLOrLater() && activity != null) { final Window window = activity.getWindow(); if (window != null) { window.setStatusBarColor(activity.getResources().getColor(colorId)); } } }
From source file:Main.java
public static int getStatusBarHeight(Activity activity) { try {//from w ww . j a v a 2 s . c o m Class<?> clazz = Class.forName("com.android.internal.R$dimen"); Object object = clazz.newInstance(); Field field = clazz.getField("status_bar_height"); int dpHeight = Integer.parseInt(field.get(object).toString()); return activity.getResources().getDimensionPixelSize(dpHeight); } catch (Exception e1) { e1.printStackTrace(); return 0; } }
From source file:Main.java
public static int getStatusHeight(Activity activity) { int statusBarHeight = 0; try {/*from ww w . j a v a 2 s . c o m*/ Class<?> c = Class.forName("com.android.internal.R$dimen"); Object o = c.newInstance(); Field field = c.getField("status_bar_height"); int x = (Integer) field.get(o); statusBarHeight = activity.getResources().getDimensionPixelSize(x); } catch (Exception e) { e.printStackTrace(); Rect frame = new Rect(); activity.getWindow().getDecorView().getWindowVisibleDisplayFrame(frame); statusBarHeight = frame.top; } return statusBarHeight; }
From source file:com.bobomee.android.common.util.ScreenUtil.java
/** * get the height of NavigationBar//w w w. jav a2 s . c o m */ public static int getNavigationBarHeight(Activity mActivity) { Resources resources = mActivity.getResources(); int resourceId = resources.getIdentifier("navigation_bar_height", "dimen", "android"); int height = resources.getDimensionPixelSize(resourceId); return height; }
From source file:com.phunkosis.gifstitch.helpers.ShareHelper.java
public static void startShareLinkIntent(Activity activity, String url) { Intent intent = new Intent(Intent.ACTION_SEND); intent.putExtra(Intent.EXTRA_TEXT, activity.getResources().getString(R.string.share_link_body) + " " + url); intent.putExtra(Intent.EXTRA_SUBJECT, activity.getResources().getString(R.string.share_link_subject)); intent.setType("text/plain"); activity.startActivity(Intent.createChooser(intent, "Share ")); }
From source file:com.example.youtubevideoupload.Util.java
public static CharSequence readFile(Activity activity, int id) { BufferedReader in = null;/*from ww w . j a va 2 s.c o m*/ try { in = new BufferedReader(new InputStreamReader(activity.getResources().openRawResource(id))); String line; StringBuilder buffer = new StringBuilder(); while ((line = in.readLine()) != null) { buffer.append(line).append('\n'); } // Chop the last newline buffer.deleteCharAt(buffer.length() - 1); return buffer; } catch (IOException e) { return ""; } finally { closeStream(in); } }
From source file:com.activiti.android.ui.utils.DisplayUtils.java
public static int getWidth(Activity context) { Display display = context.getWindowManager().getDefaultDisplay(); DisplayMetrics outMetrics = new DisplayMetrics(); display.getMetrics(outMetrics);/*ww w. j a v a 2s . com*/ float density = context.getResources().getDisplayMetrics().density; int width = Math.round(outMetrics.widthPixels / density); Resources res = context.getResources(); int coeff = 150; return coeff; }
From source file:com.qhn.bhne.xhmusic.utils.MyUtils.java
public static int getStatusBarHeight(Activity activity) { int height = 0; int resourceId = activity.getResources().getIdentifier("status_bar_height", "dimen", "android"); if (resourceId > 0) { height = activity.getResources().getDimensionPixelSize(resourceId); }/* w w w .j a v a 2 s . c o m*/ return height; }
From source file:com.actinarium.nagbox.common.ViewUtils.java
/** * Set custom icon and color for recents screen card * * @param activity Activity to configure * @param colorRes Color resource for recents screen card title * @param icon Bitmap drawable resource to draw into recents screen card title *//* w ww. j a va 2 s . c o m*/ public static void setupRecentsIcon(Activity activity, @ColorRes int colorRes, @DrawableRes int icon) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { return; } int color = ContextCompat.getColor(activity, colorRes); Bitmap bm = BitmapFactory.decodeResource(activity.getResources(), icon); ActivityManager.TaskDescription td = new ActivityManager.TaskDescription(null, bm, color); activity.setTaskDescription(td); bm.recycle(); }
From source file:Main.java
public static void updateRightImgTitle(Activity activity, int viewId, int txtRes, int imgRes) { View view = activity.findViewById(viewId); if (view == null) { return;/* www .j a v a2 s. co m*/ } if (view instanceof TextView) { view.setVisibility(View.VISIBLE); ((TextView) view).setText(activity.getString(txtRes)); Drawable drawable = activity.getResources().getDrawable(imgRes); drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight()); ((TextView) view).setCompoundDrawables(null, drawable, null, null); } }