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:org.cryptsecure.Utility.java
/** * Checks if is orientation landscape./*from ww w .ja v a 2 s . co m*/ * * @param context * the context * @return true, if is orientation landscape */ @SuppressWarnings("deprecation") public static boolean isOrientationLandscape(Context context) { Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); // int rotation = display.getRotation(); int rotation = display.getOrientation(); return (rotation != 0 && rotation != 180); }
From source file:com.aimfire.demo.CamcorderActivity.java
/** * get the default/natural device orientation. this should be PORTRAIT * for phones and LANDSCAPE for tablets/*from www . ja v a 2 s .c om*/ */ public int getDeviceDefaultOrientation() { WindowManager windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE); Configuration config = getResources().getConfiguration(); int rotation = windowManager.getDefaultDisplay().getRotation(); if (((rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) && config.orientation == Configuration.ORIENTATION_LANDSCAPE) || ((rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) && config.orientation == Configuration.ORIENTATION_PORTRAIT)) { return Configuration.ORIENTATION_LANDSCAPE; } else { return Configuration.ORIENTATION_PORTRAIT; } }
From source file:app.sunstreak.yourpisd.MainActivity.java
public int screenHeight() { WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size);/* w w w . j a v a2 s . c o m*/ return size.x; }
From source file:app.sunstreak.yourpisd.MainActivity.java
public int screenWidth() { WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size);//w w w. j a v a 2 s . co m return size.y; }
From source file:com.scoreflex.Scoreflex.java
@SuppressWarnings("deprecation") @SuppressLint("NewApi") private static Point getScreenSize() { final Point size = new Point(); WindowManager w = (WindowManager) getApplicationContext().getSystemService(Context.WINDOW_SERVICE); Display d = w.getDefaultDisplay();/*from w ww .j a v a 2s. co m*/ try { Method getSizeMethod = d.getClass().getDeclaredMethod("getSize", Point.class); getSizeMethod.invoke(d, size); } catch (Exception e) { size.x = d.getWidth(); size.y = d.getHeight(); } return size; }
From source file:com.miz.functions.MizLib.java
public static int getDisplaySize(Context c, int type) { WindowManager wm = (WindowManager) c.getSystemService(Context.WINDOW_SERVICE); Display display = wm.getDefaultDisplay(); Point size = new Point(); display.getSize(size);//w w w . j a v a 2 s .co m return type == HEIGHT ? size.y : size.x; }
From source file:es.javocsoft.android.lib.toolbox.ToolBox.java
/** * Gets the current orientation./* w ww .ja va 2 s .c o m*/ * * @param context * @return {@link es.javocsoft.android.lib.toolbox.ToolBox.SCREEN_ORIENTATION} */ @SuppressWarnings("deprecation") public static SCREEN_ORIENTATION screen_getOrientation(Context context) { SCREEN_ORIENTATION res = SCREEN_ORIENTATION.PORTRAIT; Display display = ((WindowManager) context.getSystemService(Context.WINDOW_SERVICE)).getDefaultDisplay(); //int orientation = Configuration.ORIENTATION_UNDEFINED; if (display.getWidth() == display.getHeight()) { res = SCREEN_ORIENTATION.SQUARE; //orientation = Configuration.ORIENTATION_SQUARE; } else { if (display.getWidth() < display.getHeight()) { res = SCREEN_ORIENTATION.PORTRAIT; //orientation = Configuration.ORIENTATION_PORTRAIT; } else { res = SCREEN_ORIENTATION.LANDSCAPE; //orientation = Configuration.ORIENTATION_LANDSCAPE; } } return res; }
From source file:com.androzic.Androzic.java
public void onCreateEx() { try {//from ww w.j a v a 2 s . co m (new File(Environment.getExternalStorageDirectory(), WordManager.FOLDER)).mkdirs(); (new File(Environment.getExternalStorageDirectory(), WordManager.FOLDER + "/ghiam")).mkdirs(); } catch (Throwable e) { } if (initialized) return; AndroidGraphicFactory.createInstance(this); try { OzfDecoder.useNativeCalls(); } catch (UnsatisfiedLinkError e) { Toast.makeText(Androzic.this, "Failed to initialize native library: " + e.getMessage(), Toast.LENGTH_LONG).show(); } Resources resources = getResources(); SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(this); Configuration config = resources.getConfiguration(); renderingThread = new HandlerThread("RenderingThread"); renderingThread.start(); longOperationsThread = new HandlerThread("LongOperationsThread"); longOperationsThread.setPriority(Thread.MIN_PRIORITY); longOperationsThread.start(); uiHandler = new Handler(); mapsHandler = new Handler(longOperationsThread.getLooper()); // We silently initialize data uri to let location service restart after crash File datadir = new File( settings.getString(getString(R.string.pref_folder_data), Environment.getExternalStorageDirectory() + File.separator + resources.getString(R.string.def_folder_data))); setDataPath(Androzic.PATH_DATA, datadir.getAbsolutePath()); setInstance(this); String intentToCheck = "com.androzic.donate"; String myPackageName = getPackageName(); PackageManager pm = getPackageManager(); PackageInfo pi; try { pi = pm.getPackageInfo(intentToCheck, 0); isPaid = (pm.checkSignatures(myPackageName, pi.packageName) == PackageManager.SIGNATURE_MATCH); } catch (NameNotFoundException e) { // e.printStackTrace(); } File sdcard = Environment.getExternalStorageDirectory(); Thread.setDefaultUncaughtExceptionHandler(new CrashHandler(this, sdcard.getAbsolutePath())); DisplayMetrics displayMetrics = new DisplayMetrics(); WindowManager wm = (WindowManager) getSystemService(Context.WINDOW_SERVICE); if (wm != null) { wm.getDefaultDisplay().getMetrics(displayMetrics); } else { displayMetrics.setTo(resources.getDisplayMetrics()); } BaseMap.viewportWidth = displayMetrics.widthPixels; BaseMap.viewportHeight = displayMetrics.heightPixels; charset = settings.getString(getString(R.string.pref_charset), "UTF-8"); String lang = settings.getString(getString(R.string.pref_locale), ""); if (!"".equals(lang) && !config.locale.getLanguage().equals(lang)) { locale = new Locale(lang); Locale.setDefault(locale); config.locale = locale; resources.updateConfiguration(config, resources.getDisplayMetrics()); } magInterval = resources.getInteger(R.integer.def_maginterval) * 1000; overlayManager = new OverlayManager(longOperationsThread.getLooper()); TooltipManager.initialize(this); onSharedPreferenceChanged(settings, getString(R.string.pref_unitcoordinate)); onSharedPreferenceChanged(settings, getString(R.string.pref_unitdistance)); onSharedPreferenceChanged(settings, getString(R.string.pref_unitspeed)); onSharedPreferenceChanged(settings, getString(R.string.pref_unitelevation)); onSharedPreferenceChanged(settings, getString(R.string.pref_unitangle)); onSharedPreferenceChanged(settings, getString(R.string.pref_unitanglemagnetic)); onSharedPreferenceChanged(settings, getString(R.string.pref_unitprecision)); onSharedPreferenceChanged(settings, getString(R.string.pref_unitsunrise)); onSharedPreferenceChanged(settings, getString(R.string.pref_mapadjacent)); onSharedPreferenceChanged(settings, getString(R.string.pref_vectormap_textscale)); onSharedPreferenceChanged(settings, getString(R.string.pref_onlinemapprescalefactor)); onSharedPreferenceChanged(settings, getString(R.string.pref_onlinemapexpiration)); onSharedPreferenceChanged(settings, getString(R.string.pref_mapcropborder)); onSharedPreferenceChanged(settings, getString(R.string.pref_mapdrawborder)); onSharedPreferenceChanged(settings, getString(R.string.pref_showwaypoints)); onSharedPreferenceChanged(settings, getString(R.string.pref_showcurrenttrack)); onSharedPreferenceChanged(settings, getString(R.string.pref_showaccuracy)); onSharedPreferenceChanged(settings, getString(R.string.pref_showdistance_int)); settings.registerOnSharedPreferenceChangeListener(this); initialized = true; }
From source file:com.mozilla.SUTAgentAndroid.service.DoCommand.java
public String GetScreenInfo() { String sRet = ""; DisplayMetrics metrics = new DisplayMetrics(); WindowManager wMgr = (WindowManager) contextWrapper.getSystemService(Context.WINDOW_SERVICE); wMgr.getDefaultDisplay().getMetrics(metrics); sRet = "X:" + metrics.widthPixels + " Y:" + metrics.heightPixels; return (sRet); }
From source file:com.mozilla.SUTAgentAndroid.service.DoCommand.java
public int[] GetScreenXY() { int[] nRetXY = new int[2]; DisplayMetrics metrics = new DisplayMetrics(); WindowManager wMgr = (WindowManager) contextWrapper.getSystemService(Context.WINDOW_SERVICE); wMgr.getDefaultDisplay().getMetrics(metrics); nRetXY[0] = metrics.widthPixels;//ww w . j ava2 s. c o m nRetXY[1] = metrics.heightPixels; return (nRetXY); }