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.mantz_it.rfanalyzer.SettingsFragment.java

/**
 * Will set the screen orientation of the hosting activity
 *
 * @param orientation      auto, landscape, portrait, reverse_landscape or reverse_portrait
 *///  ww  w . j  av a 2s  .c  o  m
public void setScreenOrientation(String orientation) {
    if (orientation.equals("auto"))
        getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
    else if (orientation.equals("landscape"))
        getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    else if (orientation.equals("portrait"))
        getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    else if (orientation.equals("reverse_landscape"))
        getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
    else if (orientation.equals("reverse_portrait"))
        getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
}

From source file:com.jinfukeji.jinyihuiup.indexBannerClick.ZhiboActivity.java

private void playbyFullscreen() {
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
}

From source file:com.nbplus.vbroadlauncher.BroadcastWebViewActivity.java

private void setContentViewByOrientation() {
    int wallpapereId = LauncherSettings.getInstance(this).getWallpaperId();
    int orientation = DisplayUtils.getScreenOrientation(this);
    if (orientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
            || orientation == ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE) {
        mWebViewClient.setBackgroundResource(LauncherSettings.landWallpaperResource[wallpapereId]);
    } else {//from w w  w  . j  a  va2s . c  o m
        mWebViewClient.setBackgroundResource(LauncherSettings.portWallpaperResource[wallpapereId]);
    }
}

From source file:hyplink.net.pot.GameActivity.java

@TargetApi(Build.VERSION_CODES.GINGERBREAD)
private void toogleOrientation() {
    int orientation = getRequestedOrientation();
    switch (orientation) {
    case ActivityInfo.SCREEN_ORIENTATION_PORTRAIT:
        orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
        break;/* w w w. j  a  v  a2s .c  o  m*/
    case ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE:
        orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;
        break;
    case ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT:
        orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
        break;
    default:
        orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
        break;
    }
    gamePreferences.saveOrientationSetting(orientation);
    setRequestedOrientation(orientation);
}

From source file:com.nbplus.vbroadlauncher.RadioActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (Constants.OPEN_BETA_PHONE && LauncherSettings.getInstance(this).isSmartPhone()) {
        this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    }// ww  w . j  a  v  a  2  s.c o m

    mSettingsContentObserver = new SettingsContentObserver(this, new Handler());
    getApplicationContext().getContentResolver().registerContentObserver(
            android.provider.Settings.System.CONTENT_URI, true, mSettingsContentObserver);

    showProgressDialog();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        Window window = getWindow();
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.setStatusBarColor(getResources().getColor(R.color.activity_radio_background));
    }

    overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
    setContentView(R.layout.activity_radio);

    Intent i = getIntent();
    mShortcutData = i.getParcelableExtra(Constants.EXTRA_NAME_SHORTCUT_DATA);
    if (mShortcutData == null) {
        Log.e(TAG, "mShortcutData is not found..");
        finishActivity();
        return;
    }

    IntentFilter filter = new IntentFilter();
    filter.addAction(MusicService.ACTION_PLAYED);
    filter.addAction(MusicService.ACTION_PAUSED);
    filter.addAction(MusicService.ACTION_STOPPED);
    filter.addAction(MusicService.ACTION_COMPLETED);
    filter.addAction(MusicService.ACTION_ERROR);
    filter.addAction(MusicService.ACTION_PLAYING_STATUS);

    LocalBroadcastManager.getInstance(this).registerReceiver(mBroadcastReceiver, filter);
    // send playing status
    Intent queryStatus = new Intent(this, MusicService.class);
    queryStatus.setAction(MusicService.ACTION_PLAYING_STATUS);
    startService(queryStatus);

    // ViewPager .
    // ??? ? ? ? .
    mViewPager = (NbplusViewPager) findViewById(R.id.viewPager);
    mIndicator = (CirclePageIndicator) findViewById(R.id.indicator);

    // close button
    ImageButton closeButton = (ImageButton) findViewById(R.id.btn_close);
    closeButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            finishActivity();
        }
    });

    mActivityLayout = (RelativeLayout) findViewById(R.id.radio_activity_background);
    int wallpaperId = LauncherSettings.getInstance(this).getWallpaperId();
    mActivityLayout.setBackgroundResource(LauncherSettings.landWallpaperResource[wallpaperId]);

    // title.
    mRadioTitle = (TextView) findViewById(R.id.radio_activity_label);

    // media controller
    mPlayToggle = (ImageButton) findViewById(R.id.ic_media_control_play);
    mPlayToggle.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mCurrentPlayingStatus == null) {
                return;
            }
            MusicService.State state = (MusicService.State) mCurrentPlayingStatus
                    .getSerializable(MusicService.EXTRA_PLAYING_STATUS);
            Intent i = new Intent(RadioActivity.this, MusicService.class);
            if (state == MusicService.State.Playing) {
                i.setAction(MusicService.ACTION_PAUSE);
            } else if (state == MusicService.State.Paused) {
                i.setAction(MusicService.ACTION_PLAY);
            }
            startService(i);
        }
    });
    mPlayStop = (ImageButton) findViewById(R.id.ic_media_control_stop);
    mPlayStop.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (mCurrentPlayingStatus == null) {
                return;
            }
            MusicService.State state = (MusicService.State) mCurrentPlayingStatus
                    .getSerializable(MusicService.EXTRA_PLAYING_STATUS);
            if (state == MusicService.State.Playing || state == MusicService.State.Paused) {
                Intent i = new Intent(RadioActivity.this, MusicService.class);
                i.setAction(MusicService.ACTION_STOP);
                i.putExtra(MusicService.EXTRA_MUSIC_FORCE_STOP, false);
                startService(i);
            }
        }
    });

    mSoundToggle = (ImageButton) findViewById(R.id.ic_media_control_volume_btn);
    AudioManager audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
    int currentVolume = audio.getStreamVolume(AudioManager.STREAM_MUSIC);
    int maxVolume = audio.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
    if (currentVolume <= 0) {
        mSoundToggle.setBackgroundResource(R.drawable.ic_button_radio_sound_off);
    } else {
        mSoundToggle.setBackgroundResource(R.drawable.ic_button_radio_sound_on);
    }
    mSoundToggle.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            AudioManager audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE);

            if (audio.getStreamVolume(AudioManager.STREAM_MUSIC) <= 0) {
                if (mSoundTogglePreviousValue > 0) {
                    audio.setStreamVolume(AudioManager.STREAM_MUSIC, mSoundTogglePreviousValue,
                            AudioManager.FLAG_PLAY_SOUND);
                } else {
                    mSoundTogglePreviousValue = 1;
                    audio.setStreamVolume(AudioManager.STREAM_MUSIC, mSoundTogglePreviousValue,
                            AudioManager.FLAG_PLAY_SOUND);
                }
                mSoundToggle.setBackgroundResource(R.drawable.ic_button_radio_sound_on);
                mSeekbar.setProgress(mSoundTogglePreviousValue);
                mSoundTogglePreviousValue = -1;
            } else {
                mSoundTogglePreviousValue = audio.getStreamVolume(AudioManager.STREAM_MUSIC);
                audio.setStreamVolume(AudioManager.STREAM_MUSIC, 0, AudioManager.FLAG_PLAY_SOUND);
                mSoundToggle.setBackgroundResource(R.drawable.ic_button_radio_sound_off);
            }
        }
    });

    mSeekbar = (SeekBar) findViewById(R.id.ic_media_control_volume_seek);
    mSeekbar.setMax(maxVolume);
    mSeekbar.setProgress(currentVolume);
    mSeekbar.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            if (fromUser) {
                mSoundTogglePreviousValue = -1;
                AudioManager audio = (AudioManager) getSystemService(Context.AUDIO_SERVICE);
                audio.setStreamVolume(AudioManager.STREAM_MUSIC, progress, AudioManager.FLAG_PLAY_SOUND);
            }
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {

        }
    });

    getRadioChannelTask = new GetRadioChannelTask();
    if (getRadioChannelTask != null) {
        getRadioChannelTask.setBroadcastApiData(this, mHandler,
                mShortcutData.getDomain() + mShortcutData.getPath());
        mIsExecuteGetRadioChannelTask = true;
        getRadioChannelTask.execute();
    }
}

From source file:com.Beat.RingdroidEditActivity.java

/**
 * Every time we get a message that our waveform drew, see if we need to
 * animate and trigger another redraw.//from   www .  j a v a 2  s .co m
 */
public void waveformDraw() {
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    mWidth = mWaveformView.getMeasuredWidth();
    if (mOffsetGoal != mOffset && !mKeyDown)
        updateDisplay();
    else if (mIsPlaying) {
        updateDisplay();
    } else if (mFlingVelocity != 0) {
        updateDisplay();
    }
}

From source file:org.skt.runtime.RuntimeChromeClient.java

@Override
public void onShowCustomView(View view, WebChromeClient.CustomViewCallback callback) {

    ctx.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    //Log.i(LOGTAG, "here in on ShowCustomView");
    ctx.appView.setVisibility(View.GONE);

    // if a view already exists then immediately terminate the new one
    if (ctx.appView.mCustomView != null) {
        callback.onCustomViewHidden();//from  ww w.j ava 2 s  . co  m
        return;
    }

    ctx.appView.mCustomViewContainer.addView(view);
    ctx.appView.mCustomView = view;
    ctx.appView.mCustomViewCallback = callback;
    ctx.appView.mCustomViewContainer.setVisibility(View.VISIBLE);
}

From source file:tr.com.turkcellteknoloji.turkcellupdater.Utilities.java

@SuppressLint("NewApi")
static int getScreenOrientation(Activity activity) {
    if (Build.VERSION.SDK_INT < 8) {
        switch (activity.getResources().getConfiguration().orientation) {
        case Configuration.ORIENTATION_PORTRAIT:
            return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
        case Configuration.ORIENTATION_LANDSCAPE:
            return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
        default:// w  w  w . java 2 s .  co m
            return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
        }
    }

    int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
    DisplayMetrics dm = new DisplayMetrics();
    activity.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:
            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:
            orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
            break;
        }
    }

    return orientation;
}

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

private 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;
        }//from  w w  w  . j  a  va  2 s .co  m
    }
}

From source file:uk.co.pjmobile.mobile_apps.page_turner_reader.ReadingActivity.java

private void updateFromPrefs() {

    //      this.progressService.setConfig(this.config);

    bookView.setTextSize(config.getTextSize());

    int marginH = config.getHorizontalMargin();
    int marginV = config.getVerticalMargin();

    bookView.setFontFamily(config.getFontFamily());

    bookView.setHorizontalMargin(marginH);
    bookView.setVerticalMargin(marginV);

    if (!isAnimating()) {
        bookView.setEnableScrolling(config.isScrollingEnabled());
    }//  w w  w  . j a v  a2s.c om

    bookView.setStripWhiteSpace(config.isStripWhiteSpaceEnabled());
    bookView.setLineSpacing(config.getLineSpacing());

    if (config.isFullScreenEnabled()) {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
    } else {
        getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
        getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }

    restoreColorProfile();

    // Check if we need a restart
    if (config.isBrightnessControlEnabled() != oldBrightness
            || config.isStripWhiteSpaceEnabled() != oldStripWhiteSpace
            || !this.oldFontName.equalsIgnoreCase(config.getFontFamily().getName())) {
        restartReader();
    }

    Configuration.OrientationLock orientation = config.getScreenOrientation();

    switch (orientation) {
    case PORTRAIT:
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        break;
    case LANDSCAPE:
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        break;
    case REVERSE_LANDSCAPE:
        setRequestedOrientation(8); // Android 2.3+ value
        break;
    case REVERSE_PORTRAIT:
        setRequestedOrientation(9); // Android 2.3+ value
        break;
    default:
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
    }
}