Example usage for android.content.pm ActivityInfo SCREEN_ORIENTATION_PORTRAIT

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

Introduction

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

Prototype

int SCREEN_ORIENTATION_PORTRAIT

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

Click Source Link

Document

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

Usage

From source file:com.jecelyin.editor.v2.ui.MainActivity.java

private void setScreenOrientation() {
    int orgi = pref.getScreenOrientation();

    if (Pref.SCREEN_ORIENTATION_AUTO == orgi) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
    } else if (Pref.SCREEN_ORIENTATION_LANDSCAPE == orgi) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    } else if (Pref.SCREEN_ORIENTATION_PORTRAIT == orgi) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }//  w w w.j  a v a 2s .  c o m
}

From source file:com.coact.kochzap.CaptureActivity.java

private int getCurrentOrientation() {
    int rotation = getWindowManager().getDefaultDisplay().getRotation();
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE) {
        switch (rotation) {
        case Surface.ROTATION_0:
        case Surface.ROTATION_90:
            return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
        default://w ww  .  j a  v a  2  s  . c om
            return ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
        }
    } else {
        switch (rotation) {
        case Surface.ROTATION_0:
        case Surface.ROTATION_270:
            return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
        default:
            return ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
        }
    }
}

From source file:com.segma.trim.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    MobileAds.initialize(getApplicationContext(), ADMOB_KEY);
    setContentView(R.layout.activity_main);
    loadAds();/*from w ww  .j av  a2s.  c  o m*/
    MEMORY_SIZE = ((ActivityManager) getSystemService(ACTIVITY_SERVICE)).getMemoryClass();
    MAX_BITMAP_PIXELS = calculateMaxBitmapPixels();
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    ipv = (ImageProcessingView) findViewById(R.id.ipv);
    loadLicense();
    loadUserSetting();
    final Runnable runnableOnTextView = new Runnable() {
        @Override
        public void run() {
            ipv.setVisibility(View.VISIBLE);
            // TODO: update pending: the image enlarges due to larger space
            rawBitmap = getSampleImage();
            rawBitmapWidth = rawBitmap.getWidth();
            rawBitmapHeight = rawBitmap.getHeight();
            STATE = STATE_PROCESSING_IMAGE;
            textView.setVisibility(View.GONE);
            ipv.process(rawBitmap);
        }
    };
    Display display = getWindowManager().getDefaultDisplay();
    Point size = new Point();
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB_MR2) {
        display.getSize(size);
        screenWidth = size.x;
        screenHeight = size.y;
    } else {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        screenWidth = display.getWidth();
        screenHeight = display.getHeight();
    }

    initControls();
    textView = (TextView) findViewById(R.id.tv_message);
    textView.setEnabled(false);
    ViewTreeObserver viewTreeObserver = ipv.getViewTreeObserver();
    if (viewTreeObserver.isAlive()) {
        viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                ImageProcessingViewWidth = ipv.getWidth();
                ImageProcessingViewHeight = ipv.getHeight();
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
                    ipv.getViewTreeObserver().removeOnGlobalLayoutListener(this);
                } else {
                    ipv.getViewTreeObserver().removeGlobalOnLayoutListener(this);
                }
                if (ImageProcessingViewHeight != 0)
                    textView.setEnabled(true);
            }
        });
    }
    textView.setText(MESSAGE_STARTUP);
    textView.setOnTouchListener(new View.OnTouchListener() {
        float original_text_size;

        @Override
        public boolean onTouch(View v, final MotionEvent event) {
            switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                original_text_size = textView.getTextSize();
                //textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, Math.round(original_text_size * 1.15));
                handlerOnTextView.postDelayed(runnableOnTextView, LONG_PRESS_TIME_ON_TEXTVIEW);
                textView.setEnabled(false);
                break;
            case MotionEvent.ACTION_MOVE:
                handlerOnTextView.removeCallbacks(runnableOnTextView);
                break;
            case MotionEvent.ACTION_UP:
                //textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, original_text_size);
                handlerOnTextView.removeCallbacks(runnableOnTextView);
                v.setEnabled(true);
                break;
            }
            return false;
        }
    });
    setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
    actionBar = getSupportActionBar();
    //actionBar.setDisplayHomeAsUpEnabled(true);
    ipv.setVisibility(View.INVISIBLE);

    if (MODE_DEBUG) {
        LICENSE = LICENSE_PREMIUM;
        getPackageManager().clearPackagePreferredActivities(getApplicationContext().getPackageName());
    }
}

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 ww  .  ja  va 2s .co  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:com.jinfukeji.jinyihuiup.indexBannerClick.ZhiboActivity.java

private void setLandOnClick() {
    mivfinish.setOnClickListener(new View.OnClickListener() {
        @Override/*from   w  w w  .  j  ava  2  s .c o  m*/
        public void onClick(View view) {
            ZhiboActivity.this.finish();
        }
    });
    mivPlayLand.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            initplayer();
        }
    });
    mGSzhiboLand.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (isShowLayout) {
                mLayoutConterl.setVisibility(View.GONE);
                mLayoutBack.setVisibility(View.GONE);
            } else {
                mLayoutBack.setVisibility(View.VISIBLE);
                mLayoutConterl.setVisibility(View.VISIBLE);
            }
            isShowLayout = !isShowLayout;
        }
    });
    msbAudioLand.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
        @Override
        public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            changeAudio(progress);
        }

        @Override
        public void onStartTrackingTouch(SeekBar seekBar) {

        }

        @Override
        public void onStopTrackingTouch(SeekBar seekBar) {

        }
    });
    mivNormalScreen.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        }
    });
}

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 {//from w  ww . ja v  a 2  s  .  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  w ww  .j  a v  a 2  s  .co 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.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;
        }//from   ww  w .  ja va2  s .  c  om
    } 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: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  av a2  s.co 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.smc.tw.waltz.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    if (DEBUG)//  w ww.jav  a 2 s  .co m
        Log.d(TAG, "onCreate");

    overridePendingTransition(R.anim.slide_right_in, R.anim.slide_left_out);

    super.onCreate(savedInstanceState);

    Fabric.with(this, new Crashlytics());

    setContentView(R.layout.activity_main);

    mPowerManager = (PowerManager) getSystemService(Context.POWER_SERVICE);
    mAudioManager = (AudioManager) getSystemService(Context.AUDIO_SERVICE);

    mWakeLock = mPowerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK, TAG);

    mPreferences = PreferenceManager.getDefaultSharedPreferences(this);

    mFragmentManager = getSupportFragmentManager();

    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);

    mAudioRecordBufferSize = 5600;//AudioRecord.getMinBufferSize(8000, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT)*10;
    mAudioRecord = new AudioRecord(MediaRecorder.AudioSource.MIC, 8000, AudioFormat.CHANNEL_IN_MONO,
            AudioFormat.ENCODING_PCM_16BIT, mAudioRecordBufferSize);

    mNotifyChannelList = new ArrayList<String>();

    setupLayout();

    if (savedInstanceState != null) {
        mCurrentSelectedPosition = savedInstanceState.getInt(STATE_SELECTED_POSITION);
    }

    //      mRegistrationBroadcastReceiver = new BroadcastReceiver() {
    //         @Override
    //         public void onReceive(Context context, Intent intent) {
    //
    //            // checking for type intent filter
    //            if (intent.getAction().equals(MainApplication.REGISTRATION_COMPLETE)) {
    //               // gcm successfully registered
    //               // now subscribe to `global` topic to receive app wide notifications
    //               String token = intent.getStringExtra("token");
    //
    //               //Toast.makeText(getApplicationContext(), "GCM registration token: " + token, Toast.LENGTH_LONG).show();
    //
    //            } else if (intent.getAction().equals(MainApplication.SENT_TOKEN_TO_SERVER)) {
    //               // gcm registration id is stored in our server's MySQL
    //
    //               Toast.makeText(getApplicationContext(), "GCM registration token is stored in server!", Toast.LENGTH_LONG).show();
    //
    //            } else if (intent.getAction().equals(MainApplication.PUSH_NOTIFICATION)) {
    //               // new push notification is received
    //
    //               Toast.makeText(getApplicationContext(), "Push notification is received!", Toast.LENGTH_LONG).show();
    //            }
    //         }
    //      };
    //
    if (checkPlayServices()) {
        registerGCM();
    }

}