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.duinopeak.balanbot.BalanbotActivity.java

@Override
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR2)
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    activity = this;
    context = getApplicationContext();/*from w  w  w.j av a2  s  . 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)
            BalanbotActivity.appVersion = mPackageManager.getPackageInfo(getPackageName(), 0).versionName; // Read the app version name
    } catch (NameNotFoundException e) {
        e.printStackTrace();
    }
}

From source file:co.taqat.call.LinphoneActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    //This must be done before calling super.onCreate().
    super.onCreate(savedInstanceState);

    if (getResources().getBoolean(R.bool.orientation_portrait_only)) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }//w  w w .  j ava 2 s.  c o m

    boolean useFirstLoginActivity = getResources().getBoolean(R.bool.display_account_assistant_at_first_start);
    if (LinphonePreferences.instance().isProvisioningLoginViewEnabled()) {
        Intent wizard = new Intent();
        wizard.setClass(this, RemoteProvisioningLoginActivity.class);
        wizard.putExtra("Domain", LinphoneManager.getInstance().wizardLoginViewDomain);
        startActivity(wizard);
        finish();
        return;
    } else if (savedInstanceState == null
            && (useFirstLoginActivity && LinphonePreferences.instance().isFirstLaunch())) {
        if (LinphonePreferences.instance().getAccountCount() > 0) {
            LinphonePreferences.instance().firstLaunchSuccessful();
        } else {
            startActivity(new Intent().setClass(this, AssistantActivity.class));
            finish();
            return;
        }
    }

    if (getIntent() != null && getIntent().getExtras() != null) {
        newProxyConfig = getIntent().getExtras().getBoolean("isNewProxyConfig");
    }

    if (getResources().getBoolean(R.bool.use_linphone_tag)) {
        if (getPackageManager().checkPermission(Manifest.permission.WRITE_SYNC_SETTINGS,
                getPackageName()) != PackageManager.PERMISSION_GRANTED) {
            checkSyncPermission();
        } else {
            ContactsManager.getInstance().initializeSyncAccount(getApplicationContext(), getContentResolver());
        }
    } else {
        ContactsManager.getInstance().initializeContactManager(getApplicationContext(), getContentResolver());
    }

    setContentView(R.layout.main);
    instance = this;
    fragmentsHistory = new ArrayList<FragmentsAvailable>();
    pendingFragmentTransaction = FragmentsAvailable.UNKNOW;

    initButtons();
    initSideMenu();

    currentFragment = FragmentsAvailable.EMPTY;
    if (savedInstanceState == null) {
        changeCurrentFragment(FragmentsAvailable.DIALER, getIntent().getExtras());
    } else {
        currentFragment = (FragmentsAvailable) savedInstanceState.getSerializable("currentFragment");
    }

    mListener = new LinphoneCoreListenerBase() {
        @Override
        public void messageReceived(LinphoneCore lc, LinphoneChatRoom cr, LinphoneChatMessage message) {
            displayMissedChats(getUnreadMessageCount());
        }

        @Override
        public void registrationState(LinphoneCore lc, LinphoneProxyConfig proxy,
                LinphoneCore.RegistrationState state, String smessage) {
            if (state.equals(RegistrationState.RegistrationCleared)) {
                if (lc != null) {
                    LinphoneAuthInfo authInfo = lc.findAuthInfo(proxy.getIdentity(), proxy.getRealm(),
                            proxy.getDomain());
                    if (authInfo != null)
                        lc.removeAuthInfo(authInfo);
                }
            }

            refreshAccounts();

            if (getResources().getBoolean(R.bool.use_phone_number_validation)) {
                if (state.equals(RegistrationState.RegistrationOk)) {
                    LinphoneManager.getInstance().isAccountWithAlias();
                }
            }

            if (state.equals(RegistrationState.RegistrationFailed) && newProxyConfig) {
                newProxyConfig = false;
                if (proxy.getError() == Reason.BadCredentials) {
                    //displayCustomToast(getString(R.string.error_bad_credentials), Toast.LENGTH_LONG);
                }
                if (proxy.getError() == Reason.Unauthorized) {
                    displayCustomToast(getString(R.string.error_unauthorized), Toast.LENGTH_LONG);
                }
                if (proxy.getError() == Reason.IOError) {
                    displayCustomToast(getString(R.string.error_io_error), Toast.LENGTH_LONG);
                }
            }
        }

        @Override
        public void callState(LinphoneCore lc, LinphoneCall call, LinphoneCall.State state, String message) {
            if (state == State.IncomingReceived) {
                startActivity(new Intent(LinphoneActivity.instance(), CallIncomingActivity.class));
            } else if (state == State.OutgoingInit || state == State.OutgoingProgress) {
                startActivity(new Intent(LinphoneActivity.instance(), CallOutgoingActivity.class));
            } else if (state == State.CallEnd || state == State.Error || state == State.CallReleased) {
                resetClassicMenuLayoutAndGoBackToCallIfStillRunning();
            }

            int missedCalls = LinphoneManager.getLc().getMissedCallsCount();
            displayMissedCalls(missedCalls);
        }
    };

    int missedCalls = LinphoneManager.getLc().getMissedCallsCount();
    displayMissedCalls(missedCalls);

    int rotation = getWindowManager().getDefaultDisplay().getRotation();
    switch (rotation) {
    case Surface.ROTATION_0:
        rotation = 0;
        break;
    case Surface.ROTATION_90:
        rotation = 90;
        break;
    case Surface.ROTATION_180:
        rotation = 180;
        break;
    case Surface.ROTATION_270:
        rotation = 270;
        break;
    }

    LinphoneManager.getLc().setDeviceRotation(rotation);
    mAlwaysChangingPhoneAngle = rotation;
}

From source file:com.CloudRecognition.CloudReco.java

@Override
protected void onResume() {
    Log.d(LOGTAG, "onResume");
    super.onResume();

    // This is needed for some Droid devices to force portrait
    if (mIsDroidDevice) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }/*w  w  w. j  a va  2 s  .  co m*/

    try {
        vuforiaAppSession.resumeAR();
    } catch (SampleApplicationException e) {
        Log.e(LOGTAG, e.getString());
    }

    // Resume the GL view:
    if (mGlView != null) {
        mGlView.setVisibility(View.VISIBLE);
        mGlView.onResume();
    }

}

From source file:de.dmxcontrol.activity.ControlActivity.java

@Override
protected void onStart() {
    super.onStart();

    switch (SCREEN_MODE) {
    case Prefs.SCREEN_MODE_AUTOMATIC:
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
        break;//from w  w  w . j a v  a  2  s  .  c  o  m
    case Prefs.SCREEN_MODE_PORTRAIT:
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        break;
    case Prefs.SCREEN_MODE_LANDSCAPE:
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    }

    ServiceFrontend.get().setNetworkListener(mMessageListener);
    mUpdatePanel = new UpdatePanel();

}

From source file:com.orangelabs.rcs.ri.extension.messaging.MessagingSessionView.java

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

    mCnxManager = ConnectionManager.getInstance();

    /* Set layout */
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    setContentView(R.layout.extension_session_view);

    /* Set buttons callback */
    Button sendBtn = (Button) findViewById(R.id.send_btn);
    sendBtn.setOnClickListener(btnSendListener);
    sendBtn.setEnabled(false);//from  ww w .  ja v  a  2s  .  co  m

    /* Register to API connection manager */
    if (!mCnxManager.isServiceConnected(RcsServiceName.MULTIMEDIA, RcsServiceName.CONTACT)) {
        Utils.showMessageAndExit(this, getString(R.string.label_service_not_available), mExitOnce);
        return;
    }
    mCnxManager.startMonitorServices(this, mExitOnce, RcsServiceName.MULTIMEDIA, RcsServiceName.CONTACT);
    try {
        /* Add service listener */
        mCnxManager.getMultimediaSessionApi().addEventListener(mServiceListener);

        initialiseMessagingSession(getIntent());
    } catch (RcsServiceException e) {
        if (LogUtils.isActive) {
            Log.e(LOGTAG, "Failed to add listener", e);
        }
        Utils.showMessageAndExit(this, getString(R.string.label_api_failed), mExitOnce);
    }
}

From source file:com.horaapps.leafpic.PlayerActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {

    case R.id.action_share:
        Intent share = new Intent(Intent.ACTION_SEND);
        Media m = new Media(ContentHelper.getPath(getApplicationContext(), getIntent().getData()));
        share.setType(m.getMIME());/* w w  w  . j a v  a  2s  .c  o  m*/
        share.putExtra(Intent.EXTRA_STREAM, getIntent().getData());
        startActivity(Intent.createChooser(share, getString(R.string.send_to)));
        return true;

    case R.id.action_settings:
        startActivity(new Intent(getApplicationContext(), SettingsActivity.class));
        return true;

    case R.id.rotate_layout:
        int rotation = (((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay()).getRotation();
        if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270)
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        else
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        showControls();
        return true;

    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:de.baumann.browser.helper.helper_main.java

public static void onStart(Activity from) {

    SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(from);
    class_SecurePreferences sharedPrefSec = new class_SecurePreferences(from, "sharedPrefSec",
            "Ywn-YM.XK$b:/:&CsL8;=L,y4", true);
    String pw = sharedPrefSec.getString("protect_PW");

    if (pw != null && pw.length() > 0) {
        if (sharedPref.getBoolean("isOpened", true)) {
            helper_main.switchToActivity(from, Activity_password.class, "", false);
        }//from   www. j  a va2 s  .c  o  m
    }
    if (sharedPref.getString("fullscreen", "2").equals("1")
            || sharedPref.getString("fullscreen", "2").equals("3")) {
        from.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }
    if (sharedPref.getString("orientation", "auto").equals("landscape")) {
        from.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    }
    if (sharedPref.getString("orientation", "auto").equals("portrait")) {
        from.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }
}

From source file:com.health.openscale.gui.OverviewFragment.java

@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
    super.setUserVisibleHint(isVisibleToUser);

    if (isVisibleToUser) {
        if ((getActivity().getResources().getConfiguration().screenLayout
                & Configuration.SCREENLAYOUT_SIZE_MASK) != Configuration.SCREENLAYOUT_SIZE_XLARGE
                && (getActivity().getResources().getConfiguration().screenLayout
                        & Configuration.SCREENLAYOUT_SIZE_MASK) != Configuration.SCREENLAYOUT_SIZE_LARGE) {
            Activity a = getActivity();/*from   www . j  a  v a2  s  .  c  o m*/
            if (a != null)
                a.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        }
    }
}

From source file:org.horaapps.leafpic.activities.PlayerActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {

    case org.horaapps.leafpic.R.id.action_share:
        Intent share = new Intent(Intent.ACTION_SEND);
        Media m = new Media(ContentHelper.getMediaPath(getApplicationContext(), getIntent().getData()));
        share.setType(m.getMimeType());// w w w  .  j a va 2  s. c o  m
        share.putExtra(Intent.EXTRA_STREAM, getIntent().getData());
        startActivity(Intent.createChooser(share, getString(org.horaapps.leafpic.R.string.send_to)));
        return true;

    case org.horaapps.leafpic.R.id.action_settings:
        startActivity(new Intent(getApplicationContext(), SettingsActivity.class));
        return true;

    case org.horaapps.leafpic.R.id.rotate_layout:
        int rotation = (((WindowManager) getSystemService(WINDOW_SERVICE)).getDefaultDisplay()).getRotation();
        if (rotation == Surface.ROTATION_90 || rotation == Surface.ROTATION_270)
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        else
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        showControls();
        return true;

    default:
        return super.onOptionsItemSelected(item);
    }
}

From source file:com.jaspersoft.android.jaspermobile.activities.share.AnnotationActivity.java

private void lockScreenOrientation() {
    if (getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    else/*from  w w w . j a v  a2s .co m*/
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}