List of usage examples for android.content.pm ActivityInfo SCREEN_ORIENTATION_FULL_SENSOR
int SCREEN_ORIENTATION_FULL_SENSOR
To view the source code for android.content.pm ActivityInfo SCREEN_ORIENTATION_FULL_SENSOR.
Click Source Link
fullSensor
in the android.R.attr#screenOrientation attribute. From source file:Main.java
public static void unlockOrientation(Activity activity) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR); }
From source file:Main.java
public static void initialize(Activity activity) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity); String orientation = prefs.getString("prefOrientation", "Null"); if ("Landscape".equals(orientation)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else if ("Portrait".equals(orientation)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } else {//from w ww . ja v a 2 s . co m activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR); } }
From source file:Main.java
public static void initialize(Activity activity) { /** //w w w .ja v a2 s . co m *gets a SharedPreferences instance that points to the default file that is used by the preference framework */ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(activity); /** * used to store latest orientation of android device */ String orientation = prefs.getString("prefOrientation", "Null"); if ("Landscape".equals(orientation)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else if ("Portrait".equals(orientation)) { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } else { activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR); } }
From source file:de.limexcomputer.cordova.plugin.rotationlock.RotationLock.java
/** * Executes the request./* ww w .j a 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: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); }//ww w. ja v a 2 s .c o m return (ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); }
From source file:org.gluu.super_gluu.app.fingerprint.FingerprintAuthenticationDialogFragment.java
@Override public void onPause() { super.onPause(); mFingerprintUiHelper.stopListening(); getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR); }
From source file:com.tkjelectronics.balanduino.BalanduinoActivity.java
@Override @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); activity = this; context = getApplicationContext();// w w w. java 2 s. c o m if (!getResources().getBoolean(R.bool.isTablet)) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // Set portrait mode only - for small screens like phones else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_USER); // Full screen rotation else setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR); // Full screen rotation new Handler().postDelayed(new Runnable() { // Hack to hide keyboard when the layout it rotated @Override public void run() { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); // Hide the keyboard - this is needed when the device is rotated imm.hideSoftInputFromWindow(getWindow().getDecorView().getApplicationWindowToken(), 0); } }, 1000); } setContentView(R.layout.activity_main); // Get local Bluetooth adapter if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) mBluetoothAdapter = ((BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE)).getAdapter(); else mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); // If the adapter is null, then Bluetooth is not supported if (mBluetoothAdapter == null) { showToast("Bluetooth is not available", Toast.LENGTH_LONG); finish(); return; } // get sensorManager and initialize sensor listeners SensorManager mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); mSensorFusion = new SensorFusion(getApplicationContext(), mSensorManager); // Set up the action bar. final ActionBar actionBar = getSupportActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setDisplayHomeAsUpEnabled(true); // Create the adapter that will return a fragment for each of the primary sections of the app. ViewPagerAdapter mViewPagerAdapter = new ViewPagerAdapter(getApplicationContext(), getSupportFragmentManager()); // Set up the ViewPager with the adapter. CustomViewPager mViewPager = (CustomViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mViewPagerAdapter); if (getResources().getBoolean(R.bool.isTablet)) mViewPager.setOffscreenPageLimit(2); // Since two fragments is selected in landscape mode, this is used to smooth things out // Bind the underline indicator to the adapter mUnderlinePageIndicator = (UnderlinePageIndicator) findViewById(R.id.indicator); mUnderlinePageIndicator.setViewPager(mViewPager); mUnderlinePageIndicator.setFades(false); // When swiping between different sections, select the corresponding // tab. We can also use ActionBar.Tab#select() to do this if we have // a reference to the Tab. mUnderlinePageIndicator.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { if (D) Log.d(TAG, "ViewPager position: " + position); if (position < actionBar.getTabCount()) // Needed for when in landscape mode actionBar.setSelectedNavigationItem(position); else mUnderlinePageIndicator.setCurrentItem(position - 1); } }); int count = mViewPagerAdapter.getCount(); Resources mResources = getResources(); boolean landscape = false; if (mResources.getBoolean(R.bool.isTablet) && mResources.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { landscape = true; count -= 1; // There is one less tab when in landscape mode } for (int i = 0; i < count; i++) { // For each of the sections in the app, add a tab to the action bar String text; if (landscape && i == count - 1) text = mViewPagerAdapter.getPageTitle(i) + " & " + mViewPagerAdapter.getPageTitle(i + 1); // Last tab in landscape mode have two titles in one tab else text = mViewPagerAdapter.getPageTitle(i).toString(); // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBar.addTab(actionBar.newTab().setText(text).setTabListener(this)); } try { PackageManager mPackageManager = getPackageManager(); if (mPackageManager != null) BalanduinoActivity.appVersion = mPackageManager.getPackageInfo(getPackageName(), 0).versionName; // Read the app version name } catch (NameNotFoundException e) { e.printStackTrace(); } }
From source file:com.edutech.eBalanbot.eBalanbotActivity.java
@Override @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); activity = this; context = getApplicationContext();//from w ww. java2s. c om if (!getResources().getBoolean(R.bool.isTablet)) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // Set portrait mode only - for small screens like phones else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_USER); // Full screen rotation else setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR); // Full screen rotation new Handler().postDelayed(new Runnable() { // Hack to hide keyboard when the layout it rotated @Override public void run() { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); // Hide the keyboard - this is needed when the device is rotated imm.hideSoftInputFromWindow(getWindow().getDecorView().getApplicationWindowToken(), 0); } }, 1000); } setContentView(R.layout.activity_main); // Get local Bluetooth adapter if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) mBluetoothAdapter = ((BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE)).getAdapter(); else mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); // If the adapter is null, then Bluetooth is not supported if (mBluetoothAdapter == null) { showToast("Bluetooth is not available", Toast.LENGTH_LONG); finish(); return; } // get sensorManager and initialize sensor listeners SensorManager mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); mSensorFusion = new SensorFusion(getApplicationContext(), mSensorManager); // Set up the action bar. final ActionBar actionBar = getSupportActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setDisplayHomeAsUpEnabled(true); // Create the adapter that will return a fragment for each of the primary sections of the app. ViewPagerAdapter mViewPagerAdapter = new ViewPagerAdapter(getApplicationContext(), getSupportFragmentManager()); // Set up the ViewPager with the adapter. CustomViewPager mViewPager = (CustomViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mViewPagerAdapter); if (getResources().getBoolean(R.bool.isTablet)) mViewPager.setOffscreenPageLimit(2); // Since two fragments is selected in landscape mode, this is used to smooth things out // Bind the underline indicator to the adapter mUnderlinePageIndicator = (UnderlinePageIndicator) findViewById(R.id.indicator); mUnderlinePageIndicator.setViewPager(mViewPager); mUnderlinePageIndicator.setFades(false); // When swiping between different sections, select the corresponding // tab. We can also use ActionBar.Tab#select() to do this if we have // a reference to the Tab. mUnderlinePageIndicator.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { if (D) Log.d(TAG, "ViewPager position: " + position); if (position < actionBar.getTabCount()) // Needed for when in landscape mode actionBar.setSelectedNavigationItem(position); else mUnderlinePageIndicator.setCurrentItem(position - 1); } }); int count = mViewPagerAdapter.getCount(); Resources mResources = getResources(); boolean landscape = false; if (mResources.getBoolean(R.bool.isTablet) && mResources.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { landscape = true; count -= 1; // There is one less tab when in landscape mode } for (int i = 0; i < count; i++) { // For each of the sections in the app, add a tab to the action bar String text; if (landscape && i == count - 1) text = mViewPagerAdapter.getPageTitle(i) + " & " + mViewPagerAdapter.getPageTitle(i + 1); // Last tab in landscape mode have two titles in one tab else text = mViewPagerAdapter.getPageTitle(i).toString(); // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBar.addTab(actionBar.newTab().setText(text).setTabListener(this)); } try { PackageManager mPackageManager = getPackageManager(); if (mPackageManager != null) eBalanbotActivity.appVersion = mPackageManager.getPackageInfo(getPackageName(), 0).versionName; // Read the app version name } catch (NameNotFoundException e) { e.printStackTrace(); } }
From source file:com.duinopeak.balanbot.BalanbotActivity.java
@Override @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2) protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); activity = this; context = getApplicationContext();// w w w. ja va 2 s .co m if (!getResources().getBoolean(R.bool.isTablet)) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); // Set portrait mode only - for small screens like phones else { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_USER); // Full screen rotation else setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR); // Full screen rotation new Handler().postDelayed(new Runnable() { // Hack to hide keyboard when the layout it rotated @Override public void run() { InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); // Hide the keyboard - this is needed when the device is rotated imm.hideSoftInputFromWindow(getWindow().getDecorView().getApplicationWindowToken(), 0); } }, 1000); } setContentView(R.layout.activity_main); // Get local Bluetooth adapter if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) mBluetoothAdapter = ((BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE)).getAdapter(); else mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); // If the adapter is null, then Bluetooth is not supported if (mBluetoothAdapter == null) { showToast("Bluetooth is not available", Toast.LENGTH_LONG); finish(); return; } // get sensorManager and initialize sensor listeners SensorManager mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE); mSensorFusion = new SensorFusion(getApplicationContext(), mSensorManager); // Set up the action bar. final ActionBar actionBar = getSupportActionBar(); actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); actionBar.setDisplayHomeAsUpEnabled(true); // Create the adapter that will return a fragment for each of the primary sections of the app. ViewPagerAdapter mViewPagerAdapter = new ViewPagerAdapter(getApplicationContext(), getSupportFragmentManager()); // Set up the ViewPager with the adapter. CustomViewPager mViewPager = (CustomViewPager) findViewById(R.id.pager); mViewPager.setAdapter(mViewPagerAdapter); if (getResources().getBoolean(R.bool.isTablet)) mViewPager.setOffscreenPageLimit(2); // Since two fragments is selected in landscape mode, this is used to smooth things out // Bind the underline indicator to the adapter mUnderlinePageIndicator = (UnderlinePageIndicator) findViewById(R.id.indicator); mUnderlinePageIndicator.setViewPager(mViewPager); mUnderlinePageIndicator.setFades(false); // When swiping between different sections, select the corresponding // tab. We can also use ActionBar.Tab#select() to do this if we have // a reference to the Tab. mUnderlinePageIndicator.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() { @Override public void onPageSelected(int position) { if (D) Log.d(TAG, "ViewPager position: " + position); if (position < actionBar.getTabCount()) // Needed for when in landscape mode actionBar.setSelectedNavigationItem(position); else mUnderlinePageIndicator.setCurrentItem(position - 1); } }); int count = mViewPagerAdapter.getCount(); Resources mResources = getResources(); boolean landscape = false; if (mResources.getBoolean(R.bool.isTablet) && mResources.getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) { landscape = true; count -= 1; // There is one less tab when in landscape mode } for (int i = 0; i < count; i++) { // For each of the sections in the app, add a tab to the action bar String text; if (landscape && i == count - 1) text = mViewPagerAdapter.getPageTitle(i) + " & " + mViewPagerAdapter.getPageTitle(i + 1); // Last tab in landscape mode have two titles in one tab else text = mViewPagerAdapter.getPageTitle(i).toString(); // Create a tab with text corresponding to the page title defined by // the adapter. Also specify this Activity object, which implements // the TabListener interface, as the callback (listener) for when // this tab is selected. actionBar.addTab(actionBar.newTab().setText(text).setTabListener(this)); } try { PackageManager mPackageManager = getPackageManager(); if (mPackageManager != null) BalanbotActivity.appVersion = mPackageManager.getPackageInfo(getPackageName(), 0).versionName; // Read the app version name } catch (NameNotFoundException e) { e.printStackTrace(); } }
From source file:com.example.smsquickform.Homescreen.java
@Override protected void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case BT_ENABLE_REQUEST: if (resultCode == RESULT_OK) { msg("Bluetooth Enabled successfully"); new SearchDevices().execute(); } else {/*from ww w . jav a 2 s. c om*/ msg("Bluetooth couldn't be enabled"); } break; case SETTINGS: //If the settings have been updated SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); String uuid = prefs.getString("prefUuid", "Null"); mDeviceUUID = UUID.fromString(uuid); Log.d(TAG, "UUID: " + uuid); String bufSize = prefs.getString("prefTextBuffer", "Null"); mBufferSize = Integer.parseInt(bufSize); String orientation = prefs.getString("prefOrientation", "Null"); Log.d(TAG, "Orientation: " + orientation); if (orientation.equals("Landscape")) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else if (orientation.equals("Portrait")) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } else if (orientation.equals("Auto")) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR); } break; default: break; } super.onActivityResult(requestCode, resultCode, data); }