Example usage for android.content.pm ActivityInfo SCREEN_ORIENTATION_LANDSCAPE

List of usage examples for android.content.pm ActivityInfo SCREEN_ORIENTATION_LANDSCAPE

Introduction

In this page you can find the example usage for android.content.pm ActivityInfo SCREEN_ORIENTATION_LANDSCAPE.

Prototype

int SCREEN_ORIENTATION_LANDSCAPE

To view the source code for android.content.pm ActivityInfo SCREEN_ORIENTATION_LANDSCAPE.

Click Source Link

Document

Constant corresponding to landscape in the android.R.attr#screenOrientation attribute.

Usage

From source file:com.agustinprats.myhrv.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    //Remove title bar
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);

    //Remove notification bar
    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

    //set content view AFTER ABOVE sequence (to avoid crash)
    this.setContentView(R.layout.fragment_basic_monitor_video);

    final Uri uri = getIntent().getData();
    // set previously saved theme
    //  setTheme(isLightTheme() ? R.style.LightTheme : R.style.DarkTheme);

    // elad change set theme to dark
    setTheme(R.style.LightTheme);/*  w ww  . j ava2  s  . co m*/

    //        setContentView(R.layout.activity_main);

    // Elad different services
    // Connect to Bluetooth service
    //Intent serviceIntent = new Intent(this, BleHeartRateService.class);
    //Intent serviceIntent = new Intent(this, BleHeartRateServiceElad.class);
    Intent serviceIntent = new Intent(this, SamsungS5HeartRateService.class);
    //Intent serviceIntent = new Intent(this, CameraHeartRateService.class);
    //Intent serviceIntent = new Intent(this, MockHeartRateService.class);
    //Intent serviceIntent = new Intent(this, USBSPOHeartRateService.class);
    bindService(serviceIntent, _heartRateServiceConn, BIND_AUTO_CREATE);
    Log.d(TAG, "binding with BleHeartRateService service");

    // Init monitor fragment
    if (savedInstanceState == null) {
        final FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        // Adds a newly created ContactDetailFragment that is instantiated with the
        // data Uri

        // Elad Camera

        _monitorFragment = BasicMonitorFragment.newInstance(uri);
        ft.add(android.R.id.content, _monitorFragment, TAG);
        ft.commit();
        /*
                  getFragmentManager().beginTransaction()
            .add(R.id.container, _monitorFragment)
            .commit(); */
    }
}

From source file:es.rgmf.libresportgps.MainActivity.java

/**
 * These methods are called from fragments through callback in these
 * fragments to show and dismiss loading dialog.
 *//*from  ww  w  .ja v a 2  s.c o m*/
@Override
public void onPreExecute() {
    // Create the progress dialog.
    mProgressDialog = new ProgressDialog(this);
    mProgressDialog.setCancelable(false);
    mProgressDialog.setMessage(getString(R.string.loading_file));
    mProgressDialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);

    // Stop rotation screen.
    int current_orientation = getResources().getConfiguration().orientation;
    if (current_orientation == Configuration.ORIENTATION_LANDSCAPE) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    } else {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }

    // Show the progress dialog.
    mProgressDialog.show();
}

From source file:com.slushpupie.deskclock.DeskClock.java

private void loadPrefs() {
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    boolean b = false;
    int i = 0;//from w w  w  . j ava 2  s  . c  o m
    String s = null;

    i = prefs.getInt("pref_version", 1);
    if (i != PREF_VERSION) {
        upgradePrefs(prefs);
    }

    lastChangelog = prefs.getString("last_changelog", "");

    s = prefs.getString("pref_keep_screen_on", "no");
    if ("auto".equals(s))
        prefsKeepSreenOn = 1;
    else if ("manual".equals(s))
        prefsKeepSreenOn = 2;
    else
        prefsKeepSreenOn = 0;

    prefsScreenBrightness = prefs.getInt("pref_screen_brightness", 50);
    prefsTempScreenBrightness = prefs.getInt("pref_screen_temp_brightness", 70);
    prefsButtonBrightness = prefs.getInt("pref_button_brightness", 50);

    setScreenLock(prefsKeepSreenOn, prefsScreenBrightness, prefsButtonBrightness);

    s = prefs.getString("pref_screen_orientation", "auto");
    if ("portrait".equals(s))
        prefsScreenOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
    else if ("landscape".equals(s))
        prefsScreenOrientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
    else
        prefsScreenOrientation = ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;

    setRequestedOrientation(prefsScreenOrientation);

    b = prefs.getBoolean("pref_military_time", false);
    if (b != prefsMilitaryTime) {
        prefsMilitaryTime = b;
        needsResizing = true;
    }

    b = prefs.getBoolean("pref_leading_zero", false);
    if (b != prefsLeadingZero) {
        prefsLeadingZero = b;
        needsResizing = true;
    }

    b = prefs.getBoolean("pref_meridiem", false);
    if (b != prefsShowMeridiem) {
        prefsShowMeridiem = b;
        needsResizing = true;
    }

    try {
        prefsFontColor = prefs.getInt("pref_color", Color.WHITE);
    } catch (NumberFormatException e) {
        prefsFontColor = Color.WHITE;
    }
    display.setColor(prefsFontColor);

    try {
        prefsBackgroundColor = prefs.getInt("pref_background_color", Color.BLACK);
    } catch (NumberFormatException e) {
        prefsBackgroundColor = Color.BLACK;
    }
    //layout.setBackgroundColor(prefsBackgroundColor);
    display.setBackgroundColor(prefsBackgroundColor);

    b = prefs.getBoolean("pref_show_seconds", false);
    if (b != prefsShowSeconds) {
        prefsShowSeconds = b;
        needsResizing = true;
    }

    prefsBlinkColon = prefs.getBoolean("pref_blink_seconds", false);

    try {
        i = Integer.valueOf(prefs.getString("pref_font", getString(R.string.pref_default_font)));
        if (i != prefsFont) {
            prefsFont = i;
            needsResizing = true;
        }
    } catch (NumberFormatException e) {
        if (prefsFont != Integer.valueOf(getString(R.string.pref_default_font))) {
            prefsFont = Integer.valueOf(getString(R.string.pref_default_font));
            needsResizing = true;
        }
    }

    prefsScreenSaverSpeed = prefs.getInt("pref_screensaver_speed", 500);
    if (prefsScreenSaverSpeed < 500)
        prefsScreenSaverSpeed = 500;
    if (prefsScreenSaverSpeed > 10000)
        prefsScreenSaverSpeed = 10000;
    b = prefs.getBoolean("pref_screensaver", false);
    if (b != prefsScreenSaver) {
        prefsScreenSaver = b;
        display.setScreenSaver(prefsScreenSaver);
        handler.removeCallbacks(runMoveDisplay);
        handler.postDelayed(runMoveDisplay, prefsScreenSaverSpeed);
        needsResizing = true;
    }

    i = prefs.getInt("pref_scale", 100);
    if (i != prefsScale) {
        prefsScale = i;
        needsResizing = true;
    }

    prefsShowHints = prefs.getBoolean("pref_hints", true);

    prefsUndockExit = prefs.getBoolean("pref_undock_exit", false);

}

From source file:org.huxizhijian.hhcomicviewer.ui.entry.GalleryActivity.java

private void preferencesSet() {
    //?/*from   w w w .j  a va2  s.  c  om*/
    SharedPreferencesManager preferencesManager = new SharedPreferencesManager(this);

    //
    if (!preferencesManager.getBoolean("time_visible", true)) {
        //?
        mTv_time.setVisibility(View.GONE);
    }
    if (!preferencesManager.getBoolean("page_visible", true)) {
        //??
        mTv_progress.setVisibility(View.GONE);
    }
    if (!preferencesManager.getBoolean("charge_visible", true)) {
        //??
        mIv_battery.setVisibility(View.GONE);
    }
    if (!preferencesManager.getBoolean("number_visible", false)) {
        //??
        mIsCenterPositionVisible = false;
    }
    if (preferencesManager.getBoolean("keep_screen_on", false)) {
        //?
        mMenu.setKeepScreenOn(true);
    }
    loadOnLineFullSizeImage = preferencesManager.getBoolean("reading_full_size_image", false);
    useVolButtonChangePage = preferencesManager.getBoolean("use_volume_key", false);

    String rotate = preferencesManager.getString("reading_screen_rotate", "none");
    if ("portrait".equals(rotate)) {
        //???
        if (getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_PORTRAIT) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        }
    } else if ("landscape".equals(rotate)) {
        //???
        if (getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        }
    }

    //
    String directionValue = preferencesManager.getString("reading_direction", "view_pager");
    if ("view_pager".equals(directionValue)) {
        mReadingDirection = VIEW_PAGER;
    } else if ("list_view".equals(directionValue)) {
        mReadingDirection = LIST_VIEW;
        mTv_position.setVisibility(View.GONE);
    }

}

From source file:org.mklab.mikity.android.MainActivity.java

/**
 * ??????/*w w  w.  j  a va  2 s  .  co m*/
 */
public void controlRotation() {
    final Configuration configuration = getResources().getConfiguration();
    final int rotation = ((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay().getRotation();
    boolean isReverse = false;

    if (this.settingsFragment.rotationLockButton.isChecked()) {
        switch (rotation) {
        case Surface.ROTATION_180:
        case Surface.ROTATION_270:
            isReverse = true;
            break;
        default:
            isReverse = false;
            break;
        }

        if (configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) {
            if (isReverse) {
                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
            } else {
                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
            }
        } else {
            if (isReverse) {
                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
            } else {
                setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
            }
        }
        MainActivity.this.canvasFragment.objectRenderer.updateDisplay();
    } else {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER);
    }
}

From source file:de.spiritcroc.modular_remote.MainActivity.java

@Override
protected void onResume() {
    super.onResume();
    appWidgetHost.startListening();/*from  w  ww  . j  a  v a 2s.c  o  m*/

    tcpConnectionManager.refreshConnections();

    viewPager.addOnPageChangeListener(this);
    onPageSelected(viewPager.getCurrentItem());

    int tmp = Util.getPreferenceInt(sharedPreferences, Preferences.OFFSCREEN_PAGE_LIMIT, 2);
    if (tmp < 0) {
        neverDestroyPages = true;
        viewPager.setOffscreenPageLimit(pages.size());
    } else {
        neverDestroyPages = false;
        viewPager.setOffscreenPageLimit(tmp);
    }

    fullscreen = sharedPreferences.getBoolean(Preferences.FULLSCREEN, false);
    hideNavigationBar = sharedPreferences.getBoolean(Preferences.HIDE_NAVIGATION_BAR, false);
    hideActionBar = sharedPreferences.getBoolean(Preferences.HIDE_ACTION_BAR, false);

    int pagerTabStripVisibility = sharedPreferences.getBoolean(Preferences.HIDE_PAGER_TAB_STRIP, false)
            ? View.GONE
            : View.VISIBLE;
    if (pagerTabStrip.getVisibility() != pagerTabStripVisibility) {
        pagerTabStrip.setVisibility(pagerTabStripVisibility);
    }

    String ringerMode = sharedPreferences.getString(Preferences.CHANGE_RINGER_MODE,
            getString(R.string.pref_ringer_mode_keep_value));
    AudioManager audioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    previousRingerMode = audioManager.getRingerMode();
    if (getString(R.string.pref_ringer_mode_mute_value).equals(ringerMode)) {
        audioManager.setRingerMode(AudioManager.RINGER_MODE_SILENT);
        changedRingerMode = true;
    } else if (getString(R.string.pref_ringer_mode_vibrate_value).equals(ringerMode)) {
        audioManager.setRingerMode(AudioManager.RINGER_MODE_VIBRATE);
        changedRingerMode = true;
    } else if (getString(R.string.pref_ringer_mode_vibrate_if_not_muted_value).equals(ringerMode)
            && previousRingerMode != AudioManager.RINGER_MODE_SILENT) {
        audioManager.setRingerMode(AudioManager.RINGER_MODE_VIBRATE);
        changedRingerMode = true;
    }

    if (forceOrientation == FORCE_ORIENTATION_PORTRAIT) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    } else if (forceOrientation == FORCE_ORIENTATION_LANDSCAPE) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    } else {
        String orientation = sharedPreferences.getString(Preferences.ORIENTATION,
                Preferences.ORIENTATION_SHARE_LAYOUT);
        if (Preferences.ORIENTATION_PORTRAIT_ONLY.equals(orientation)) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        } else if (Preferences.ORIENTATION_LANDSCAPE_ONLY.equals(orientation)) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        } else {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_USER);
        }
    }

    resizeContent();

    setLockedModeVisibilities();
}

From source file:org.cm.podd.report.activity.SettingActivity.java

private void captureImageFromCamera() {
    mCurrentPhotoUri = getImageUri();/*from   www.ja va 2s  . co m*/
    Intent photoTakerIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
    photoTakerIntent.putExtra(MediaStore.EXTRA_SIZE_LIMIT, 1024 * 1024);
    photoTakerIntent.putExtra(MediaStore.EXTRA_SCREEN_ORIENTATION, ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    photoTakerIntent.putExtra(MediaStore.EXTRA_OUTPUT, mCurrentPhotoUri);
    if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP) {
        photoTakerIntent
                .addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            photoTakerIntent.setClipData(ClipData.newRawUri("", mCurrentPhotoUri));
        }
    }
    startActivityForResult(photoTakerIntent, REQ_CODE_TAKE_IMAGE);
}

From source file:im.ene.lab.toro.ext.layeredvideo.PlaybackControlLayer.java

/**
 * Fullscreen mode will rotate to landscape mode, hide the action bar, hide the navigation bar,
 * hide the system tray, and make the video player take up the full size of the display.
 * The developer who is using this function must ensure the following:
 *
 * <p>1) Inside the android manifest, the activity that uses the video player has the attribute
 * android:configChanges="orientation"./*from  w  ww  .ja  v a  2  s.  com*/
 *
 * <p>2) Other views in the activity (or fragment) are
 * hidden (or made visible) when this method is called.
 */
public void doToggleFullscreen() {
    // If there is no callback for handling fullscreen, don't do anything.
    if (fullscreenCallback == null) {
        return;
    }

    ObservablePlayerControl playerControl = layerManager.getControl();
    if (playerControl == null) {
        return;
    }

    Activity activity = layerManager.getActivity();
    FrameLayout container = layerManager.getContainer();

    if (isFullscreen) {
        activity.setRequestedOrientation(savedOrientation);

        // Make the status bar and navigation bar visible again.
        activity.getWindow().getDecorView().setSystemUiVisibility(0);

        container.setLayoutParams(originalContainerLayoutParams);

        fullscreenButton.setImageResource(R.drawable.toro_ext_ic_fullscreen_enter);

        fullscreenCallback.onReturnFromFullscreen();
        isFullscreen = false;
    } else {
        savedOrientation = activity.getResources().getConfiguration().orientation;
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

        activity.getWindow().getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
                        | View.SYSTEM_UI_FLAG_FULLSCREEN | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY);

        container.setLayoutParams(PlayerUtil.getLayoutParamsBasedOnParent(container,
                ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

        fullscreenButton.setImageResource(R.drawable.toro_ext_ic_fullscreen_exit);
        fullscreenCallback.onGoToFullscreen();
        isFullscreen = true;
    }
}

From source file:com.tweetlanes.android.core.view.ComposeBaseFragment.java

protected void lockScreenRotation() {
    if (getActivity() != null) {
        switch (getActivity().getResources().getConfiguration().orientation) {
        case Configuration.ORIENTATION_PORTRAIT:
            getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
            break;
        case Configuration.ORIENTATION_LANDSCAPE:
            getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
            break;
        }//ww w . ja v a2s .c om
    }
}

From source file:cz.tomsuch.lampicka.activities.LampActivity.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:/* w  w w  .  j a v  a  2  s.  c  om*/
            Log.e("WTF", "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:
            Log.e("WTF", "Unknown screen orientation. Defaulting to " + "landscape.");
            orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
            break;
        }
    }

    return orientation;
}