List of usage examples for android.content.pm ActivityInfo SCREEN_ORIENTATION_SENSOR
int SCREEN_ORIENTATION_SENSOR
To view the source code for android.content.pm ActivityInfo SCREEN_ORIENTATION_SENSOR.
Click Source Link
sensor
in the android.R.attr#screenOrientation attribute. From source file:Main.java
public static void unlockScreenOrientation(Activity activity) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); }
From source file:Main.java
public static void restoreOrientation(Activity activity, int orientation) { if (activity != null) { activity.setRequestedOrientation(orientation); activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); }/*from w w w. j ava2s . com*/ }
From source file:Main.java
public static void toggleOrientation(Context context, boolean enable) { if (!enable) { ((Activity) context).setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } else {// w ww .java2 s. com ((Activity) context).setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); } }
From source file:com.landenlabs.all_devtool.DevFragment.java
/** * Called when fragment selected (visible) *//*from www .ja va 2 s.c o m*/ public void onSelected() { GoogleAnalyticsHelper.event(this.getActivity(), "activity", "selected", getName()); GlobalInfo.s_globalInfo.mainFragActivity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); GlobalInfo.s_globalInfo.mainFragActivity.getWindow() .clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); }
From source file:com.sonyericsson.demo.Demo.java
/** Constant used as menu item id for resetting zoom state */ @Override// w w w . j a va2s. c o m public void onCreate(Bundle savedInstanceState) { requestWindowFeature(Window.FEATURE_NO_TITLE); getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); super.onCreate(savedInstanceState); setContentView(R.layout.main); // get page indicator textview m_tv = (TextView) findViewById(R.id.full_image_indicator); vp = (ViewPager) findViewById(R.id.viewpager); vpAdapter = new ViewPagerAdapter(m_pics, this); vp.setAdapter(vpAdapter); vp.setOnPageChangeListener(this); vp.setCurrentItem(m_imageIdx); setCurIndicator(m_imageIdx); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); }
From source file:com.manning.androidhacks.hack029.MainActivity.java
public void allowOrientationChanges() { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); }
From source file:de.limexcomputer.cordova.plugin.rotationlock.RotationLock.java
/** * Executes the request./*from w ww . ja v a 2 s . c o m*/ * * This method is called from the WebView thread. * To do a non-trivial amount of work, use: * cordova.getThreadPool().execute(runnable); * * To run on the UI thread, use: * cordova.getActivity().runOnUiThread(runnable); * * @param action The action to execute. * @param args The exec() arguments in JSON form. * @param callback The callback context used when calling back into JavaScript. * @return Whether the action was valid. */ @Override public boolean execute(String action, JSONArray args, CallbackContext callback) throws JSONException { if (!action.equalsIgnoreCase("setOrientation")) { return false; } String orientation = args.optString(0); Activity activity = this.cordova.getActivity(); // refer to https://github.com/their/pg-plugin-screen-orientation/blob/master/src/ScreenOrientation.java if (orientation.equals(UNSPECIFIED)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); } else if (orientation.equals(LANDSCAPE)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else if (orientation.equals(PORTRAIT)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } else if (orientation.equals(USER)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER); } else if (orientation.equals(BEHIND)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_BEHIND); } else if (orientation.equals(SENSOR)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); } else if (orientation.equals(NOSENSOR)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR); } else if (orientation.equals(SENSOR_LANDSCAPE)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); } else if (orientation.equals(SENSOR_PORTRAIT)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); } else if (orientation.equals(REVERSE_LANDSCAPE)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE); } else if (orientation.equals(REVERSE_PORTRAIT)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT); } else if (orientation.equals(FULL_SENSOR)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR); } callback.success(orientation); return true; }
From source file:com.google.zxing.client.android.history.HistoryActivity.java
@Override public void pegaScreenResolution() { DisplayMetrics metrics = new DisplayMetrics(); getWindowManager().getDefaultDisplay().getMetrics(metrics); int height = metrics.heightPixels; int width = metrics.widthPixels; Log.i("Script", " Tela do dispositivo - " + height + "x" + width); // pegar - largura por altura if (width <= 780 && height <= 1080) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } else {//from w w w . j av a 2s . c o m setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); } }
From source file:org.apache.cordova.screenorientation.ScreenOrientation.java
public int getOrientation(String orientation) { if (orientation.equals(UNSPECIFIED)) { return (ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); } else if (orientation.equals(LANDSCAPE)) { return (ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else if (orientation.equals(PORTRAIT)) { return (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } else if (orientation.equals(USER)) { return (ActivityInfo.SCREEN_ORIENTATION_USER); } else if (orientation.equals(BEHIND)) { return (ActivityInfo.SCREEN_ORIENTATION_BEHIND); } else if (orientation.equals(SENSOR)) { return (ActivityInfo.SCREEN_ORIENTATION_SENSOR); } else if (orientation.equals(NOSENSOR)) { return (ActivityInfo.SCREEN_ORIENTATION_NOSENSOR); } else if (orientation.equals(SENSOR_LANDSCAPE)) { return (ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE); } else if (orientation.equals(SENSOR_PORTRAIT)) { return (ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); } else if (orientation.equals(REVERSE_LANDSCAPE)) { return (ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE); } else if (orientation.equals(REVERSE_PORTRAIT)) { return (ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT); } else if (orientation.equals(FULL_SENSOR)) { return (ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR); }/*from w w w. j a v a 2 s. c o m*/ return (ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); }
From source file:com.snu_artoon.arwebtoonplayer.WebtoonView.WebtoonViewActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.lock_rotate: setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); return true; case R.id.unlock_rotate: setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); return true; case R.id.capture: captureScreen();//from www. j ava 2 s. c om return true; default: return false; } }