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.m2dl.mini_projet.mini_projet_android.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    if (screenIsLarge()) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    } else {/*from  w ww  . j ava2  s  .  c  om*/
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }

    myPhotoMarkers = new HashMap<>();

    locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    if (ActivityCompat.checkSelfPermission(this,
            Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
        return;
    }
    locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 3000, 5, this);

    if (!locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER)) {
        buildAlertMessageNoGps();
    } else {
        isGPSOn = true;
    }

    coordLat = 0.0;
    coordLong = 0.0;

    FloatingActionButton fabPhoto = (FloatingActionButton) findViewById(R.id.fabPhoto);
    fabPhoto.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            takePhoto(view);
        }
    });

    FloatingActionButton fabTagSelect = (FloatingActionButton) findViewById(R.id.fabTagSelect);
    fabTagSelect.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            selectTags();
        }
    });

    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
            .findFragmentById(R.id.map);
    mapFragment.getMapAsync(this);

    pointInteretManager = new PointInteretManager(this);

    // Init tag list
    allTags = new TreeSet<>();
    selectedTags = new TreeSet<>();
}

From source file:fr.cph.stock.android.activity.ChartActivity.java

/**
 * //from   w w w  . j  a va  2s . c  o m
 * @return
 */
private String getData() {
    DisplayMetrics metrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(metrics);
    String data = null;
    try {
        InputStream is = null;
        StringWriter writer = new StringWriter();
        switch (chartType) {
        case CAPITALIZATION:
            is = getApplicationContext().getAssets().open("www/pie.html");
            IOUtils.copy(is, writer, "UTF8");
            data = writer.toString();
            data = data.replace("#DATA#", portfolio.getChartCapData());
            data = data.replace("#TITLE#", portfolio.getChartCapTitle());
            data = data.replace("#DRAW#", portfolio.getChartCapDraw());
            data = data.replace("#COMPANIES#", portfolio.getChartCapCompanies());
            data = data.replaceAll("#WIDTH#", (int) (metrics.widthPixels / metrics.density) - 30 + "");
            data = data.replaceAll("#HEIGHT#", (int) (metrics.widthPixels / metrics.density) - 30 + "");
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
            actionBar.setTitle("Capitalization Chart");
            webView.setHorizontalScrollBarEnabled(false);
            break;
        case SECTOR:
            is = getApplicationContext().getAssets().open("www/pie.html");
            IOUtils.copy(is, writer, "UTF8");
            data = writer.toString();
            data = data.replace("#DATA#", portfolio.getChartSectorData());
            data = data.replace("#TITLE#", portfolio.getChartSectorTitle());
            data = data.replace("#DRAW#", portfolio.getChartSectorDraw());
            data = data.replace("#COMPANIES#", portfolio.getChartSectorCompanies());
            data = data.replaceAll("#WIDTH#", (int) (metrics.widthPixels / metrics.density) - 30 + "");
            data = data.replaceAll("#HEIGHT#", (int) (metrics.widthPixels / metrics.density) - 30 + "");
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
            actionBar.setTitle("Sector Chart");
            webView.setHorizontalScrollBarEnabled(false);
            break;
        case SHARE_VALUE:
            is = getApplicationContext().getAssets().open("www/share_value.html");
            IOUtils.copy(is, writer, "UTF8");
            data = writer.toString();
            data = data.replace("#DATA#", portfolio.getChartData());
            data = data.replace("#DRAW#", portfolio.getChartDraw());
            data = data.replace("#COLOR#", portfolio.getChartColors());
            data = data.replace("#DATE#", portfolio.getChartDate());
            data = data.replaceAll("#WIDTH#", ((int) (metrics.widthPixels / metrics.density)) - 30 + "");
            data = data.replaceAll("#HEIGHT#", (int) (metrics.heightPixels / metrics.density / 1.35) + "");
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
            actionBar.setTitle("Share Value Chart");
            break;
        }
    } catch (IOException e) {
        Log.e(TAG, "", e);
    }
    return data;
}

From source file:com.shimi.camera.must.stand.straight.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    mRootView = findViewById(R.id.root_view);
    mCameraView = (CameraView) findViewById(R.id.camera);
    if (mCameraView != null) {
        mCameraView.addCallback(mCallback);
    }// w ww  .ja  v  a2 s . co  m
    mCaptureFab = (FloatingActionButton) findViewById(R.id.take_picture);
    if (mCaptureFab != null) {
        mCaptureFab.setOnClickListener(mOnClickListener);
    }
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    ActionBar actionBar = getSupportActionBar();
    if (actionBar != null) {
        actionBar.setDisplayShowTitleEnabled(false);
    }
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    mSensorManager = (SensorManager) getSystemService(SENSOR_SERVICE);
}

From source file:co.taqat.call.assistant.AssistantActivity.java

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

    if (getResources().getBoolean(R.bool.orientation_portrait_only)) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }/*from   ww  w .  j av a2s .  co  m*/

    setContentView(R.layout.assistant);
    initUI();

    if (getIntent().getBooleanExtra("LinkPhoneNumber", false)) {
        isLink = true;
        //if (getIntent().getBooleanExtra("FromPref",false)){
        //   fromPref = true;
        //displayCreateAccount();
    } else {
        firstFragment = getResources().getBoolean(R.bool.assistant_use_linphone_login_as_first_fragment)
                ? AssistantFragmentsEnum.LINPHONE_LOGIN
                : AssistantFragmentsEnum.WELCOME;
        if (findViewById(R.id.fragment_container) != null) {
            if (savedInstanceState == null) {
                display(firstFragment);
            } else {
                currentFragment = (AssistantFragmentsEnum) savedInstanceState
                        .getSerializable("CurrentFragment");
            }
        }
    }
    if (savedInstanceState != null && savedInstanceState.containsKey("echoCanceller")) {
        echoCancellerAlreadyDone = savedInstanceState.getBoolean("echoCanceller");
    } else {
        echoCancellerAlreadyDone = false;
    }
    mPrefs = LinphonePreferences.instance();
    status.enableSideMenu(false);

    accountCreator = LinphoneCoreFactory.instance().createAccountCreator(LinphoneManager.getLc(),
            LinphonePreferences.instance().getXmlrpcUrl());
    accountCreator.setDomain(getResources().getString(R.string.default_domain));
    accountCreator.setListener(this);

    countryListAdapter = new CountryListAdapter(getApplicationContext());
    mListener = new LinphoneCoreListenerBase() {

        @Override
        public void configuringStatus(LinphoneCore lc, final LinphoneCore.RemoteProvisioningState state,
                String message) {
            if (progress != null)
                progress.dismiss();
            if (state == LinphoneCore.RemoteProvisioningState.ConfiguringSuccessful) {
                goToLinphoneActivity();
            } else if (state == LinphoneCore.RemoteProvisioningState.ConfiguringFailed) {
                Toast.makeText(AssistantActivity.instance(), getString(R.string.remote_provisioning_failure),
                        Toast.LENGTH_LONG).show();
            }
        }

        @Override
        public void registrationState(LinphoneCore lc, LinphoneProxyConfig cfg, RegistrationState state,
                String smessage) {
            if (remoteProvisioningInProgress) {
                if (progress != null)
                    progress.dismiss();
                if (state == RegistrationState.RegistrationOk) {
                    remoteProvisioningInProgress = false;
                    success();
                }
            } else if (accountCreated && !newAccount) {
                if (address != null && address.asString().equals(cfg.getAddress().asString())) {
                    if (state == RegistrationState.RegistrationOk) {
                        if (progress != null)
                            progress.dismiss();
                        if (LinphoneManager.getLc().getDefaultProxyConfig() != null) {
                            accountCreator.isAccountUsed();
                        }
                    } else if (state == RegistrationState.RegistrationFailed) {
                        if (progress != null)
                            progress.dismiss();
                        if (dialog == null || !dialog.isShowing()) {
                            dialog = createErrorDialog(cfg, smessage);
                            dialog.show();
                        }
                    } else if (!(state == RegistrationState.RegistrationProgress)) {
                        if (progress != null)
                            progress.dismiss();
                    }
                }
            }
        }
    };
    instance = this;
}

From source file:com.example.android.materialdesigncodelab.activities.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    //noinspection SimplifiableIfStatement
    if (id == R.id.action_normal) {
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        RadioApplication.isPortrait = true;
    } else if (id == R.id.action_car) {
        activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        RadioApplication.isPortrait = false;
    }//ww w.j  a  va  2 s  . c  om
    return super.onOptionsItemSelected(item);
}

From source file:com.kawunglabs.olimpiadeuiapp.HelpActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    setContentView(R.layout.activity_help);
    resources = getResources();/*from  w ww  .ja v a  2  s  .  co m*/

    // Create an adapter that when requested, will return a fragment representing an object in
    // the collection.
    // 
    // ViewPager and its adapters use support library fragments, so we must use
    // getSupportFragmentManager.
    mDemoCollectionPagerAdapter = new DemoCollectionPagerAdapter(getSupportFragmentManager());

    // Set up action bar.
    final ActionBar actionBar = getActionBar();

    // Specify that the Home button should show an "Up" caret, indicating that touching the
    // button will take the user one step up in the application's hierarchy.
    actionBar.setDisplayHomeAsUpEnabled(true);

    // Set up the ViewPager, attaching the adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mDemoCollectionPagerAdapter);
}

From source file:divya.myvision.TessActivity.java

/**
 * Initializes the UI and creates the detector pipeline.
 *///  ww  w  . j  a  va  2 s  .co m
@Override
public void onCreate(Bundle icicle) {
    super.onCreate(icicle);

    setContentView(R.layout.ocr_capture);

    mPreview = (CameraSourcePreview) findViewById(R.id.preview);
    mGraphicOverlay = (GraphicOverlay<TessGraphic>) findViewById(R.id.graphicOverlay);

    // read parameters from the intent used to launch the activity.
    boolean autoFocus = getIntent().getBooleanExtra(AutoFocus, false);
    boolean useFlash = getIntent().getBooleanExtra(UseFlash, false);
    String fps = getIntent().getStringExtra(FPS);
    String fontSize = getIntent().getStringExtra(FontSize);
    String orientation = getIntent().getStringExtra(Orientation);
    String lang = getIntent().getStringExtra(Lang);

    if (orientation.equals("Landscape")) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    } else if (orientation.equals("Portrait")) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    } else {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
    }

    Settings.setFontSize(Float.parseFloat(fontSize));

    // Check for the camera permission before accessing the camera.  If the
    // permission is not granted yet, request permission.
    int rc = ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA);
    if (rc == PackageManager.PERMISSION_GRANTED) {
        createCameraSource(autoFocus, useFlash, fps);
    } else {
        requestCameraPermission();
    }

    gestureDetector = new GestureDetector(this, new CaptureGestureListener());
    scaleGestureDetector = new ScaleGestureDetector(this, new ScaleListener());

    Snackbar.make(mGraphicOverlay, R.string.info_msg, Snackbar.LENGTH_LONG).show();

    setLang(lang);
}

From source file:org.linphone.assistant.AssistantActivity.java

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

    if (getResources().getBoolean(R.bool.orientation_portrait_only)) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }/*from w ww  .  j  a  va 2s.  c  om*/

    setContentView(R.layout.assistant);
    initUI();

    if (getIntent().getBooleanExtra("LinkPhoneNumber", false)) {
        isLink = true;
        if (getIntent().getBooleanExtra("FromPref", false))
            fromPref = true;
        displayCreateAccount();
    } else {
        firstFragment = getResources().getBoolean(R.bool.assistant_use_linphone_login_as_first_fragment)
                ? AssistantFragmentsEnum.LINPHONE_LOGIN
                : AssistantFragmentsEnum.WELCOME;
        if (findViewById(R.id.fragment_container) != null) {
            if (savedInstanceState == null) {
                display(firstFragment);
            } else {
                currentFragment = (AssistantFragmentsEnum) savedInstanceState
                        .getSerializable("CurrentFragment");
            }
        }
    }
    if (savedInstanceState != null && savedInstanceState.containsKey("echoCanceller")) {
        echoCancellerAlreadyDone = savedInstanceState.getBoolean("echoCanceller");
    } else {
        echoCancellerAlreadyDone = false;
    }
    mPrefs = LinphonePreferences.instance();
    status.enableSideMenu(false);

    accountCreator = LinphoneCoreFactory.instance().createAccountCreator(LinphoneManager.getLc(),
            LinphonePreferences.instance().getXmlrpcUrl());
    accountCreator.setListener(this);

    countryListAdapter = new CountryListAdapter(getApplicationContext());
    mListener = new LinphoneCoreListenerBase() {

        @Override
        public void configuringStatus(LinphoneCore lc, final LinphoneCore.RemoteProvisioningState state,
                String message) {
            if (progress != null)
                progress.dismiss();
            if (state == LinphoneCore.RemoteProvisioningState.ConfiguringSuccessful) {
                goToLinphoneActivity();
            } else if (state == LinphoneCore.RemoteProvisioningState.ConfiguringFailed) {
                Toast.makeText(AssistantActivity.instance(), getString(R.string.remote_provisioning_failure),
                        Toast.LENGTH_LONG).show();
            }
        }

        @Override
        public void registrationState(LinphoneCore lc, LinphoneProxyConfig cfg, RegistrationState state,
                String smessage) {
            if (remoteProvisioningInProgress) {
                if (progress != null)
                    progress.dismiss();
                if (state == RegistrationState.RegistrationOk) {
                    remoteProvisioningInProgress = false;
                    success();
                }
            } else if (accountCreated && !newAccount) {
                if (address != null && address.asString().equals(cfg.getAddress().asString())) {
                    if (state == RegistrationState.RegistrationOk) {
                        if (progress != null)
                            progress.dismiss();
                        if (getResources().getBoolean(R.bool.use_phone_number_validation)
                                && cfg.getDomain().equals(getString(R.string.default_domain))
                                && LinphoneManager.getLc().getDefaultProxyConfig() != null) {
                            accountCreator.isAccountUsed();
                        } else {
                            success();
                        }
                    } else if (state == RegistrationState.RegistrationFailed) {
                        if (progress != null)
                            progress.dismiss();
                        if (dialog == null || !dialog.isShowing()) {
                            dialog = createErrorDialog(cfg, smessage);
                            dialog.setCancelable(false);
                            dialog.show();
                        }
                    } else if (!(state == RegistrationState.RegistrationProgress)) {
                        if (progress != null)
                            progress.dismiss();
                    }
                }
            }
        }
    };
    instance = this;
}

From source file:io.github.msc42.masterthemaze.SearchDeviceActivity.java

private void lockScreenOrientation() {
    int orientation = getResources().getConfiguration().orientation;
    int rotation = getWindowManager().getDefaultDisplay().getRotation();

    if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
        if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_90) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        } else {//  ww  w .ja  va2  s .co  m
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
        }
    } else if (orientation == Configuration.ORIENTATION_PORTRAIT) {
        if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_90) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        } else {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT);
        }
    } else {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    }
}

From source file:org.kontalk.util.SystemUtils.java

/**
 * Returns the correct screen orientation based on the supposedly preferred
 * position of the device.//from  ww w  .  j a  va  2s . c o  m
 * http://stackoverflow.com/a/16585072/1045199
 */
public static int getScreenOrientation(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:
            return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
        case Surface.ROTATION_90:
            return ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
        case Surface.ROTATION_180:
            return ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
        case Surface.ROTATION_270:
            return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
        }
    } else {
        // Natural position is Portrait
        switch (rotation) {
        case Surface.ROTATION_0:
            return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
        case Surface.ROTATION_90:
            return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
        case Surface.ROTATION_180:
            return ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
        case Surface.ROTATION_270:
            return ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
        }
    }

    return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
}