List of usage examples for android.content Context WINDOW_SERVICE
String WINDOW_SERVICE
To view the source code for android.content Context WINDOW_SERVICE.
Click Source Link
From source file:FacebookImageLoader.java
public static int calculateDensityDpi(Context context) { if (mDensityDpi > 0) { // we've already calculated it return mDensityDpi; }/* w w w . j a v a 2s .c o m*/ if (Integer.parseInt(Build.VERSION.SDK) <= 3) { // 1.5 devices are all medium density mDensityDpi = DENSITY_MEDIUM; return mDensityDpi; } DisplayMetrics metrics = new DisplayMetrics(); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); wm.getDefaultDisplay().getMetrics(metrics); int reflectedDensityDpi = DENSITY_MEDIUM; try { reflectedDensityDpi = DisplayMetrics.class.getDeclaredField("mDensityDpi").getInt(metrics); } catch (Exception e) { e.printStackTrace(); } mDensityDpi = reflectedDensityDpi; return mDensityDpi; }
From source file:com.farmerbb.secondscreen.util.U.java
public static boolean runDensityCommand(Context context, String requestedDpi) { DisplayMetrics metrics = new DisplayMetrics(); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display disp = wm.getDefaultDisplay(); disp.getRealMetrics(metrics);/*from w w w . j a v a2s. co m*/ SharedPreferences prefMain = getPrefMain(context); String currentDpi; String nativeDpi = Integer .toString(SystemProperties.getInt("ro.sf.lcd_density", prefMain.getInt("density", 0))); if (prefMain.getBoolean("debug_mode", false)) { SharedPreferences prefCurrent = getPrefCurrent(context); currentDpi = prefCurrent.getString("density", "reset"); if ("reset".equals(currentDpi)) currentDpi = nativeDpi; } else currentDpi = Integer.toString(metrics.densityDpi); if (requestedDpi.equals("reset")) requestedDpi = nativeDpi; return !requestedDpi.equals(currentDpi); }
From source file:com.adwhirl.AdWhirlManager.java
private Custom parseCustomJsonString(String jsonString) { Log.d(AdWhirlUtil.ADWHIRL, "Received custom jsonString: " + jsonString); Custom custom = new Custom(); try {// w w w.j a v a2 s . c o m JSONObject json = new JSONObject(jsonString); custom.type = json.getInt("ad_type"); custom.imageLink = json.getString("img_url"); custom.link = json.getString("redirect_url"); custom.description = json.getString("ad_text"); // Populate high-res house ad info if available // TODO(wesgoodman): remove try/catch block after upgrading server to // new protocol. try { custom.imageLink480x75 = json.getString("img_url_480x75"); } catch (JSONException e) { custom.imageLink480x75 = null; } DisplayMetrics metrics = new DisplayMetrics(); ((WindowManager) contextReference.get().getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay() .getMetrics(metrics); if (metrics.density == 1.5 && custom.type == AdWhirlUtil.CUSTOM_TYPE_BANNER && custom.imageLink480x75 != null && custom.imageLink480x75.length() != 0) { custom.image = fetchImage(custom.imageLink480x75); } else { custom.image = fetchImage(custom.imageLink); } } catch (JSONException e) { Log.e(AdWhirlUtil.ADWHIRL, "Caught JSONException in parseCustomJsonString()", e); return null; } return custom; }
From source file:ca.nehil.rter.streamingapp.StreamingActivity.java
private void initLayout() { /* get size of screen */ Display display = ((WindowManager) getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); Point size = new Point(); display.getSize(size);//ww w . ja va 2s. c o m //size of screen screenWidth = size.x; screenHeight = size.y; FrameLayout.LayoutParams layoutParam = null; LayoutInflater myInflate = null; myInflate = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE); topLayout = new FrameLayout(this); setContentView(topLayout); mGLView = overlay.getGLView(); // OpenGLview int display_width_d = (int) (1.0 * screenWidth); int display_height_d = (int) (1.0 * screenHeight); int button_width = 0; int button_height = 0; int prev_rw, prev_rh; if (1.0 * display_width_d / display_height_d > 1.0 * live_width / live_height) { prev_rh = display_height_d; button_height = display_height_d; prev_rw = (int) (1.0 * display_height_d * live_width / live_height); button_width = display_width_d - prev_rw; } else { prev_rw = display_width_d; prev_rh = (int) (1.0 * display_width_d * live_height / live_width); } layoutParam = new FrameLayout.LayoutParams(1, 1, Gravity.BOTTOM); Log.d("LAYOUT", "display_width_d:" + display_width_d + ":: display_height_d:" + display_height_d + ":: prev_rw:" + prev_rw + ":: prev_rh:" + prev_rh + ":: live_width:" + live_width + ":: live_height:" + live_height + ":: button_width:" + button_width + ":: button_height:" + button_height); Log.d("CameraDebug", "InitLayout acquired camera"); if (CAMERA_PREVIEW) { cameraDevice = openCamera(); cameraView = new CameraView(this, cameraDevice); topLayout.addView(cameraView, layoutParam); } layoutParam = new FrameLayout.LayoutParams(prev_rw, prev_rh, Gravity.CENTER); topLayout.addView(mGLView, layoutParam); FrameLayout preViewLayout = (FrameLayout) myInflate.inflate(R.layout.activity_streaming, null); layoutParam = new FrameLayout.LayoutParams(screenWidth, screenHeight); topLayout.addView(preViewLayout, layoutParam); Log.i(LOG_TAG, "cameara preview start: OK"); }
From source file:com.jinfukeji.jinyihuiup.indexBannerClick.ZhiboActivity.java
@Override public boolean dispatchTouchEvent(MotionEvent ev) { switch (ev.getAction()) { case MotionEvent.ACTION_DOWN: break;//from w w w. j av a 2s . c o m case MotionEvent.ACTION_MOVE: WindowManager wm = (WindowManager) this.getSystemService(Context.WINDOW_SERVICE); int width = wm.getDefaultDisplay().getWidth(); int height = wm.getDefaultDisplay().getHeight(); float rawX = ev.getRawX(); float rawY = ev.getRawY(); float x = ev.getX(); float y = ev.getY(); if (rawX < width / 2) { if (rawY < y) { streamVolume++; changeAudio(streamVolume); } else { streamVolume--; changeAudio(streamVolume); } } else { if (rawY < y) { } else { } } break; case MotionEvent.ACTION_UP: break; case MotionEvent.ACTION_SCROLL: break; } return super.dispatchTouchEvent(ev); }
From source file:com.oakesville.mythling.app.AppData.java
public Point getScreenSize() { if (screenSize == null) { WindowManager wm = (WindowManager) appContext.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); screenSize = new Point(); display.getSize(screenSize);/*from w w w . j ava2 s . c o m*/ } return screenSize; }
From source file:com.arisprung.tailgate.utilities.FacebookImageLoader.java
public static int calculateDensityDpi(Context context) { if (mDensityDpi > 0) { // we've already calculated it return mDensityDpi; }/*from www . j av a 2 s. com*/ if (Integer.parseInt(Build.VERSION.SDK) <= 3) { // 1.5 devices are all medium density mDensityDpi = DENSITY_MEDIUM; return mDensityDpi; } DisplayMetrics metrics = new DisplayMetrics(); WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); wm.getDefaultDisplay().getMetrics(metrics); int reflectedDensityDpi = DENSITY_MEDIUM; // try // { // reflectedDensityDpi = DisplayMetrics.class.getDeclaredField("mDensityDpi").getInt(metrics); // } // catch (Exception e) // { // e.printStackTrace(); // } mDensityDpi = reflectedDensityDpi; return mDensityDpi; }
From source file:it.angrydroids.epub3reader.TextSelectionSupport.java
private float getDensityDependentValue(float val, Context ctx) { Display display = ((WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); DisplayMetrics metrics = new DisplayMetrics(); display.getMetrics(metrics);/*from w ww . j a v a 2 s. com*/ return val * (metrics.densityDpi / 160f); }
From source file:it.angrydroids.epub3reader.TextSelectionSupport.java
private float getDensityIndependentValue(float val, Context ctx) { Display display = ((WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); DisplayMetrics metrics = new DisplayMetrics(); display.getMetrics(metrics);//from ww w . ja v a 2s . c o m return val / (metrics.densityDpi / 160f); }
From source file:com.pdftron.pdf.utils.Utils.java
/** * Gets the size of the display, in pixels. * * @param context the Context/*from w ww. j av a 2s .co m*/ * @param outSize A Point object to receive the size information */ public static void getDisplaySize(Context context, Point outSize) { WindowManager wm = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); if (outSize == null) { outSize = new Point(); } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) { display.getSize(outSize); } else { outSize.set(display.getWidth(), display.getHeight()); } }