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.hpush.app.activities.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Crashlytics.start(this); setContentView(LAYOUT);//from w ww .ja v a2 s .c om if (getResources().getBoolean(R.bool.landscape)) { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } getSupportFragmentManager().beginTransaction() .replace(R.id.gplus_container, GPlusFragment.newInstance(getApplication())).commit(); mHeaderView = findViewById(R.id.error_content); ViewCompat.setElevation(mHeaderView, getResources().getDimension(R.dimen.toolbar_elevation)); mToolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(mToolbar); initDrawer(); mViewPager = (ViewPager) findViewById(R.id.vp); mPagerAdapter = new MainViewPagerAdapter(this, getSupportFragmentManager()); mViewPager.setAdapter(mPagerAdapter); calcActionBarHeight(); mViewPager.setPadding(0, 2 * getActionBarHeight(), 0, 0); // Bind the tabs to the ViewPager mTabs = (PagerSlidingTabStrip) findViewById(R.id.tabs); mTabs.setViewPager(mViewPager); mTabs.setIndicatorColorResource(R.color.common_white); mTabs.setOnPageChangeListener(new OnPageChangeListener() { @Override public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { closeFloatButtons(); } @Override public void onPageSelected(int position) { propagateToolbarState(toolbarIsShown()); } @Override public void onPageScrollStateChanged(int state) { } }); propagateToolbarState(toolbarIsShown()); mRemoveAllBtn = (ImageButton) findViewById(R.id.remove_all_btn); mRemoveAllBtn.setOnClickListener(new OnViewAnimatedClickedListener() { @Override public void onClick() { EventBus.getDefault().post(new RemoveAllEvent( mViewPager.getCurrentItem() == 0 ? WhichPage.Messages : WhichPage.Bookmarks)); } }); mBookmarkAllBtn = (ImageButton) findViewById(R.id.bookmark_all_btn); mBookmarkAllBtn.setOnClickListener(new OnViewAnimatedClickedListener() { @Override public void onClick() { EventBus.getDefault().post(new BookmarkAllEvent()); } }); mOpenBtn = (ImageButton) findViewById(R.id.float_main_btn); mOpenBtn.setOnClickListener(mOpenListener); mSnackBar = new SnackBar(this); mPlusClient = new GoogleApiClient.Builder(this, this, this).addApi(Plus.API, PlusOptions.builder().build()) .addScope(Plus.SCOPE_PLUS_LOGIN).build(); mGPlusBtn = (SignInButton) findViewById(R.id.sign_in_btn); mGPlusBtn.setSize(SignInButton.SIZE_WIDE); mGPlusBtn.setOnClickListener(new OnViewAnimatedClickedListener3() { @Override public void onClick() { loginGPlus(); } }); if (!TextUtils.isEmpty(Prefs.getInstance(getApplication()).getGoogleAccount())) { mPlusClient.connect(); } mTotalTv = (TextView) findViewById(R.id.total_tv); this.refreshCurrentTotalMessages(); }
From source file:com.vuzix.samplewebrtc.android.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); requestWindowFeature(Window.FEATURE_NO_TITLE); if (TextUtils.isEmpty(SESSION_ID)) { Toast.makeText(this, ": SESSION_ID???\n" + "MainActivity.java??SESSION_ID???????", Toast.LENGTH_LONG).show(); finish();/* w w w . ja v a 2s . com*/ return; } setContentView(R.layout.activity_main); ButterKnife.bind(this); updateUis(); }
From source file:com.nextgis.maplibui.util.ControlHelper.java
@TargetApi(Build.VERSION_CODES.GINGERBREAD) public static void lockScreenOrientation(Activity activity) { WindowManager windowManager = (WindowManager) activity.getSystemService(Context.WINDOW_SERVICE); Configuration configuration = activity.getResources().getConfiguration(); int rotation = windowManager.getDefaultDisplay().getRotation(); // Search for the natural position of the device if (configuration.orientation == Configuration.ORIENTATION_LANDSCAPE && (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) || configuration.orientation == Configuration.ORIENTATION_PORTRAIT && (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270)) { // Natural position is Landscape switch (rotation) { case Surface.ROTATION_0: activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); break; case Surface.ROTATION_90: activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT); break; case Surface.ROTATION_180: activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE); break; case Surface.ROTATION_270: activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); break; }/* w w w . java 2 s . com*/ } else { // Natural position is Portrait switch (rotation) { case Surface.ROTATION_0: activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); break; case Surface.ROTATION_90: activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); break; case Surface.ROTATION_180: activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT); break; case Surface.ROTATION_270: activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE); break; } } }
From source file:com.cleverzone.zhizhi.capture.CaptureActivity.java
private int getCurrentOrientation() { int rotation = getWindowManager().getDefaultDisplay().getRotation(); switch (rotation) { case Surface.ROTATION_0: case Surface.ROTATION_90: return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; default:/*from w w w . j av a 2s .c om*/ return ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; } }
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 {/*w w w . j av a2 s . c o m*/ 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); }
From source file:org.protocoderrunner.apprunner.api.PUI.java
@ProtocoderScript @APIMethod(description = "Forces landscape mode in the app", example = "") @APIParam(params = { "mode={'landscape', 'portrait', 'other'" }) public void setScreenOrientation(String mode) { if (mode.equals("landscape")) { appRunnerActivity.get().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); } else if (mode.equals("portrait")) { appRunnerActivity.get().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); } else {/* ww w . j a va 2s. c o m*/ appRunnerActivity.get().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR); } }
From source file:org.namelessrom.devicecontrol.modules.device.SensorActivity.java
@Override protected void onResume() { super.onResume(); // lock current orientation switch (getResources().getConfiguration().orientation) { case Configuration.ORIENTATION_PORTRAIT: { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); break;/*from ww w.j a v a2 s . c o m*/ } case Configuration.ORIENTATION_LANDSCAPE: { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); break; } } // register all sensors for (final BaseSensor sensor : mSensorList) { sensor.onResume(); } }
From source file:org.namelessrom.devicecontrol.device.SensorActivity.java
@Override protected void onResume() { super.onResume(); // do not allow swiping to open menu with viewpagers MainActivity.setSwipeOnContent(false); // lock current orientation switch (getResources().getConfiguration().orientation) { case Configuration.ORIENTATION_PORTRAIT: { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); break;/*from w w w . j a v a 2s.c o m*/ } case Configuration.ORIENTATION_LANDSCAPE: { setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); break; } } // register all sensors for (final BaseSensor sensor : mSensorList) { sensor.onResume(); } }
From source file:com.google.android.testing.nativedriver.server.AndroidNativeDriver.java
@Override public void rotate(ScreenOrientation orientation) { int activityOrientation; if (orientation == ScreenOrientation.LANDSCAPE) { activityOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; } else { // ScreenOrientation.PORTRAIT activityOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; }/* ww w .j ava2 s.c om*/ context.getOnMainSyncRunner().run(doRotate(activityOrientation)); }
From source file:net.oschina.app.v2.activity.zxing.CaptureActivity.java
@Deprecated private int getCurrentOrientation() { int rotation = getWindowManager().getDefaultDisplay().getRotation(); switch (rotation) { case Surface.ROTATION_0: case Surface.ROTATION_90: return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; default:/*from www .j a va 2s . c o m*/ return ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; } }