List of usage examples for android.content.pm ActivityInfo SCREEN_ORIENTATION_LANDSCAPE
int SCREEN_ORIENTATION_LANDSCAPE
To view the source code for android.content.pm ActivityInfo SCREEN_ORIENTATION_LANDSCAPE.
Click Source Link
landscape
in the android.R.attr#screenOrientation attribute. From source file:com.brq.wallet.activity.ScanActivity.java
private int getScreenOrientation() { int rotation = getWindowManager().getDefaultDisplay().getRotation(); DisplayMetrics dm = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(dm); int width = dm.widthPixels; int height = dm.heightPixels; int orientation; // if the device's natural orientation is portrait: if ((rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) && height > width || (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270) && width > height) { switch (rotation) { case Surface.ROTATION_0: orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; break; case Surface.ROTATION_90: orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; break; case Surface.ROTATION_180: orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; break; case Surface.ROTATION_270: orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; break; default:/*from w w w. jav a 2 s . c o m*/ // Unknown screen orientation. Defaulting to portrait. orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; break; } } // if the device's natural orientation is landscape or if the device is square: else { switch (rotation) { case Surface.ROTATION_0: orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; break; case Surface.ROTATION_90: orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; break; case Surface.ROTATION_180: orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; break; case Surface.ROTATION_270: orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; break; default: // Unknown screen orientation. Defaulting to landscape. orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; break; } } return orientation; }
From source file:org.openremote.android.console.GroupActivity.java
/** * Inits a orientation listener, set request orientation be sensor when the current screen's orientation equals device orientation. *//*from w w w.j a v a2 s.c o m*/ private void initOrientationListener() { OrientationEventListener orientationListener = new OrientationEventListener(this) { @Override public void onOrientationChanged(int orientation) { if (currentScreen == null) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); return; } if (orientation > 315 || orientation < 45 || (orientation > 135 && orientation < 225)) { // portrait if (getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT && !currentScreen.isLandscape() && currentScreen.getInverseScreenId() > 0) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); } else if (!currentScreen.isLandscape() && currentScreen.getInverseScreenId() == 0) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } } else if ((orientation > 225 && orientation < 315) || (orientation > 45 && orientation < 135)) { // landscape if (getRequestedOrientation() == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE && currentScreen.isLandscape() && currentScreen.getInverseScreenId() > 0) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); } else if (currentScreen.isLandscape() && currentScreen.getInverseScreenId() == 0) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } } } }; orientationListener.enable(); }
From source file:com.CloudRecognition.CloudReco.java
@Override protected void onResume() { Log.d(LOGTAG, "onResume"); super.onResume(); // This is needed for some Droid devices to force portrait if (mIsDroidDevice) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); }//from ww w .j a v a 2 s . com try { vuforiaAppSession.resumeAR(); } catch (SampleApplicationException e) { Log.e(LOGTAG, e.getString()); } // Resume the GL view: if (mGlView != null) { mGlView.setVisibility(View.VISIBLE); mGlView.onResume(); } }
From source file:zxing.util.CaptureActivity.java
License:asdf
private int getCurrentOrientation() { int rotation = getWindowManager().getDefaultDisplay().getRotation(); switch (rotation) { case Surface.ROTATION_0: return ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT; case Surface.ROTATION_90: return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; default://from ww w . j a va2 s . c om return ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; } }
From source file:me.drakeet.meizhi.ui.GankFragment.java
@OnClick(R.id.header_appbar) void onPlayVideo() { resumeVideoView();//from w w w . ja va 2s . c o m getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); if (mGankList.size() > 0 && mGankList.get(0).type.equals("?")) { Toasts.showLongX2(R.string.loading); } else { closePlayer(); } }
From source file:de.baumann.browser.helper.helper_main.java
public static void onStart(Activity from) { SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(from); class_SecurePreferences sharedPrefSec = new class_SecurePreferences(from, "sharedPrefSec", "Ywn-YM.XK$b:/:&CsL8;=L,y4", true); String pw = sharedPrefSec.getString("protect_PW"); if (pw != null && pw.length() > 0) { if (sharedPref.getBoolean("isOpened", true)) { helper_main.switchToActivity(from, Activity_password.class, "", false); }// ww w . j ava2 s. c om } if (sharedPref.getString("fullscreen", "2").equals("1") || sharedPref.getString("fullscreen", "2").equals("3")) { from.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); } if (sharedPref.getString("orientation", "auto").equals("landscape")) { from.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } if (sharedPref.getString("orientation", "auto").equals("portrait")) { from.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } }
From source file:com.andrasta.dashi.MainActivity.java
private void setupOrientation() { int orientation = this.prefs.getInt(KEY_CAMERA_ROTATION, 90); if (orientation == 270) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE); } else if (orientation == 90) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else {//from w ww . ja va2 s. c om throw new RuntimeException("Camera orientation not supported: " + orientation); } }
From source file:com.mediatek.miravision.ui.MiraVisionActivity.java
private void selectItem(int position) { Log.d(TAG, "selectItem position: " + position); DrawerListViewEntry entry = (DrawerListViewEntry) sDrawerListAdapter.getItem(position); Fragment fragment = mFragments[(int) entry.mId]; // default fragment int orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; // default // LANDSCAPE//w ww .j a v a 2 s. c o m if (fragment instanceof ResetDialogFragment) { ResetDialogFragment resetDialog = (ResetDialogFragment) fragment; resetDialog.setResetListener(new ResetListener() { @Override public void reset() { resetPQ(); getActionBar().setTitle(R.string.mira_vision_tm); show(getFragmentManager(), new IntroductionFragment(), ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); } }); resetDialog.show(getFragmentManager(), null); mDrawerList.setItemChecked(position, true); mDrawerLayout.closeDrawer(mDrawerList); return; } // AAL and picture mode is UNSPECIFIED if (fragment instanceof AalSettingsFragment || fragment instanceof PictureModeFragment) { orientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; } // Basic and Advance tuning need know which item being selected if (fragment instanceof BasicColorTuningFragment) { fragment = new BasicColorTuningFragment(entry.mTitle); } else if (fragment instanceof AdvanceColorTuningFragment) { fragment = new AdvanceColorTuningFragment(entry.mTitle); } show(getFragmentManager(), fragment, orientation); mDrawerList.setItemChecked(position, true); setTitle(entry.mFragmentTitle); mDrawerLayout.closeDrawer(mDrawerList); }
From source file:de.dmxcontrol.activity.ControlActivity.java
@Override protected void onStart() { super.onStart(); switch (SCREEN_MODE) { case Prefs.SCREEN_MODE_AUTOMATIC: setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); break;// w ww . ja v a 2 s .c o m case Prefs.SCREEN_MODE_PORTRAIT: setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); break; case Prefs.SCREEN_MODE_LANDSCAPE: setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } ServiceFrontend.get().setNetworkListener(mMessageListener); mUpdatePanel = new UpdatePanel(); }
From source file:com.sim2dial.dialer.LinphoneActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); if (isTablet() && getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); }/*from ww w .ja v a 2s . c o m*/ if (!LinphoneManager.isInstanciated()) { Log.e("No service running: avoid crash by starting the launcher", this.getClass().getName()); finish(); startActivity(getIntent().setClass(this, LinphoneLauncherActivity.class)); return; } boolean useFirstLoginActivity = getResources().getBoolean(R.bool.use_first_login_activity); if (useFirstLoginActivity && !Engine.getPref().getBoolean(getString(R.string.first_launch_suceeded_once_key), false)) { startActivity(new Intent(LinphoneActivity.this, SetupActivity.class)); startActivityForResult(new Intent().setClass(this, SetupActivity.class), FIRST_LOGIN_ACTIVITY); finish(); } else { /* * startActivity(new * Intent(SetupActivity.this,SetupActivity.class)); finish(); */ } /* * boolean useFirstLoginActivity = * getResources().getBoolean(R.bool.use_first_login_activity); * SharedPreferences pref = * PreferenceManager.getDefaultSharedPreferences(this); if * (useFirstLoginActivity && * !pref.getBoolean(getString(R.string.first_launch_suceeded_once_key), * false)) { if (pref.getInt(getString(R.string.pref_extra_accounts), * -1) > -1) { * pref.edit().putBoolean(getString(R.string.first_launch_suceeded_once_key * ), true); } else { startActivityForResult(new Intent().setClass(this, * SetupActivity.class), FIRST_LOGIN_ACTIVITY); } } */ setContentView(R.layout.main); initButtons(); applyTheme(); instance = this; currentFragment = nextFragment = FragmentsAvailable.DIALER; if (savedInstanceState == null) { if (findViewById(R.id.fragmentContainer) != null) { dialerFragment = new DialerFragment(); dialerFragment.setArguments(getIntent().getExtras()); getSupportFragmentManager().beginTransaction().add(R.id.fragmentContainer, dialerFragment).commit(); selectMenu(FragmentsAvailable.DIALER); } } // int missedCalls = LinphoneManager.getLc().getMissedCallsCount(); // displayMissedCalls(missedCalls); int rotation = Compatibility.getRotation(getWindowManager().getDefaultDisplay()); // Inverse landscape rotation to initiate linphoneCore correctly if (rotation == 270) rotation = 90; else if (rotation == 90) rotation = 270; LinphoneManager.getLc().setDeviceRotation(rotation); mAlwaysChangingPhoneAngle = rotation; updateAnimationsState(); }