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.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;
    }//from  w ww  .  ja  v  a 2s .c  o m
    return super.onOptionsItemSelected(item);
}

From source file:ch.jeda.platform.android.CanvasFragment.java

int getOrientation(final int currentOrientation) {
    if (this.features.contains(ViewFeature.ORIENTATION_LANDSCAPE)) {
        return ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
    } else if (this.features.contains(ViewFeature.ORIENTATION_PORTRAIT)) {
        return ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
    } else {//from   w  w w.  j ava 2  s  . c om
        return currentOrientation;
    }
}

From source file:org.tunesremote.LibraryBrowseActivity.java

@SuppressLint("NewApi")
@Override//from  w ww.j ava  2 s . c om
public void onCreate(Bundle saved) {
    super.onCreate(saved);
    this.prefs = PreferenceManager.getDefaultSharedPreferences(this);
    if (this.prefs.getBoolean(this.getString(R.string.pref_fullscreen), true)
            && Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    }
    setContentView(R.layout.act_browse_library);

    artists = new ArtistsListFragment();
    albums = new AllAlbumsListFragment();
    playlists = new PlaylistsFragment();

    isTablet = findViewById(R.id.frame_artists) != null;

    if (!isTablet) {

        (pager = (ViewPager) findViewById(R.id.view_pager))
                .setAdapter(new LibraryPagerAdapter(getSupportFragmentManager()));
        pager.setOnPageChangeListener(this);
        pager.setOffscreenPageLimit(2);
        findViewById(R.id.tab_artists).setSelected(true);

    } else {

        getSupportFragmentManager().beginTransaction().add(R.id.frame_artists, artists)
                .add(R.id.frame_albums, albums).add(R.id.frame_playlists, playlists).commit();
        registerListener(artists, albums, playlists);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        handler = new TabHandler();
        ActionBar ab = getActionBar();
        ab.setTitle(R.string.control_menu_library);

        if (!isTablet) {
            findViewById(R.id.legacy_tabs).setVisibility(View.GONE);
            ab.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
            Tab artTab = ab.newTab().setText(R.string.control_menu_artists).setTabListener(handler);
            Tab albTab = ab.newTab().setText(R.string.control_menu_albums).setTabListener(handler);
            Tab plyTab = ab.newTab().setText(R.string.control_menu_playlists).setTabListener(handler);
            ab.addTab(artTab);
            ab.addTab(albTab);
            ab.addTab(plyTab);
        }

    }

}

From source file:com.scandit.simplesample.SimpleSampleActivity.java

/**
 * Initializes and starts the bar code scanning.
 *//*from   w  ww . j  a va 2  s . c  o  m*/
public void initializeAndStartBarcodeScanning() {
    // Switch to full screen.
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    requestWindowFeature(Window.FEATURE_NO_TITLE);

    // The scanning behavior of the barcode picker is configured through scan
    // settings. We start with empty scan settings and enable a very generous
    // set of symbologies. In your own apps, only enable the symbologies you
    // actually need.
    ScanSettings settings = ScanSettings.create();
    settings.setSymbologyEnabled(Barcode.SYMBOLOGY_EAN13, true);
    settings.setSymbologyEnabled(Barcode.SYMBOLOGY_UPCA, true);
    settings.setSymbologyEnabled(Barcode.SYMBOLOGY_EAN8, true);
    settings.setSymbologyEnabled(Barcode.SYMBOLOGY_UPCE, true);

    settings.setSymbologyEnabled(Barcode.SYMBOLOGY_QR, true);
    settings.setSymbologyEnabled(Barcode.SYMBOLOGY_DATA_MATRIX, true);

    settings.setSymbologyEnabled(Barcode.SYMBOLOGY_CODE39, true);
    settings.setSymbologyEnabled(Barcode.SYMBOLOGY_CODE128, true);

    settings.setSymbologyEnabled(Barcode.SYMBOLOGY_INTERLEAVED_2_OF_5, true);

    settings.setCameraFacingPreference(ScanSettings.CAMERA_FACING_BACK);

    // Some Android 2.3+ devices do not support rotated camera feeds. On these devices, the
    // barcode picker emulates portrait mode by rotating the scan UI.
    boolean emulatePortraitMode = !BarcodePicker.canRunPortraitPicker();
    if (emulatePortraitMode) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    }

    BarcodePicker picker = new BarcodePicker(this, settings);

    setContentView(picker);
    mBarcodePicker = picker;

    // Register listener, in order to be notified about relevant events 
    // (e.g. a successfully scanned bar code).
    mBarcodePicker.setOnScanListener(this);

}

From source file:eu.sathra.SathraActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mCurrentSathra = this;
    mWasInitiated = false;/*from w ww.  j a va 2s  .  c  o m*/

    ResourceManager.getInstance().unloadAll();

    mParams = getParameters();

    if (mParams.fullscreen) {
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);
    }

    if (mParams.layout == 0) {
        mSurfaceView = new GLSurfaceView(this);
        setContentView(mSurfaceView);
    } else {
        setContentView(mParams.layout);
        mSurfaceView = (GLSurfaceView) findViewById(R.id.surface);
    }

    mSurfaceView.setRenderer(this);
    mSurfaceView.getHolder().setFormat(PixelFormat.TRANSLUCENT);
    mSurfaceView.setPreserveEGLContextOnPause(true);

    // resize view to forced resolution
    if (mParams.width != 0 && mParams.height != 0)
        mSurfaceView.getHolder().setFixedSize(mParams.width, mParams.height);

    SathraAdapter adapter = new SathraAdapter();

    IO.getInstance().registerAdapter(SathraActivity.class, adapter);
    IO.getInstance().registerAdapter(Context.class, adapter);

    mIsRunning = true;

    // setup FPS view

    showFPS(mParams.showFPS);

    setTimeScale(1);

    setAmbientColor(mParams.ambientColor);

    setRequestedOrientation(
            mParams.orientation == Orientation.VERTICAL ? ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
                    : ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    // new CameraNode(this, null, null, true, null, null, null, null);
    // mRootNode.addChild(CameraNode.getActiveCamera());
}

From source file:com.example.android.weatherapp.view.MainActivity.java

/**
 * to prevent crash on screen orientation in middle of network operation
 * we will be locking orientation of the screen temporarily.
 *
 * @author swapnil/*  w w  w  .j a v  a  2 s .c om*/
 */
private void lockScreenOrientation() {
    int currentOrientation = getResources().getConfiguration().orientation;
    if (currentOrientation == Configuration.ORIENTATION_PORTRAIT) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
    } else {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    }
}

From source file:id.co.datascrip.dtswarehousesystem.activity.Form_Scan_Scandid.java

private void initScanner() {
    // Set your app key
    ScanditLicense.setAppKey(API_KEY);/*  ww w  . j  a  v a 2 s .  c  om*/

    boolean emulatePortraitMode = !BarcodePicker.canRunPortraitPicker();
    if (emulatePortraitMode) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    }

    mPicker = new BarcodePicker(this, getScanSetting());

    // Set the on scan listener to receive barcode scan events.
    mPicker.setOnScanListener(this);
    mPicker.getOverlayView().setTorchEnabled(true);
    mPicker.switchTorchOn(true);
    setContentView(mPicker);
}

From source file:com.intel.xdk.base.Base.java

public void showSplashScreen() {
    cordova.getActivity().runOnUiThread(new Runnable() {
        public void run() {
            //treat displays larger than 6" as tablets
            DisplayMetrics dm = new DisplayMetrics();
            cordova.getActivity().getWindowManager().getDefaultDisplay().getMetrics(dm);
            double x = Math.pow(dm.widthPixels / dm.xdpi, 2);
            double y = Math.pow(dm.heightPixels / dm.ydpi, 2);
            double screenInches = Math.sqrt(x + y);
            if (screenInches > 6) {
                isTablet = true;/*from   w  w  w  .j a va 2s  .c o  m*/
            }

            //used for calculating status bar height
            int deviceWidth = dm.widthPixels;
            int deviceHeight = dm.heightPixels;
            if (deviceWidth > deviceHeight) {
                deviceWidth = dm.heightPixels;
                deviceHeight = dm.widthPixels;
            }

            //get the splash screen image from asssets
            Bitmap bm = null;
            try {
                if (isTablet) {
                    bm = getBitmapFromAsset("www/intel.xdk.base/android/splash_screen_tablet.jpg");
                } else {
                    bm = getBitmapFromAsset("www/intel.xdk.base/android/splash_screen.jpg");
                }
            } catch (IOException ioe) {
            }

            //if the splash screen assets are missing, don't try to show the splash screen
            if (bm == null) {
                return;
            }

            if (Debug.isDebuggerConnected())
                Log.i("[intel.xdk]", "splash");

            ActivityInfo ai = null;
            int splashViewId = 0;
            try {
                ai = cordova.getActivity().getPackageManager().getActivityInfo(
                        cordova.getActivity().getComponentName(),
                        PackageManager.GET_ACTIVITIES | PackageManager.GET_META_DATA);

                if (isTablet) {
                    if (ai.screenOrientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
                        splashViewId = cordova.getActivity().getResources().getIdentifier("splash_tablet_ls",
                                "layout", cordova.getActivity().getPackageName());
                    } else {
                        splashViewId = cordova.getActivity().getResources().getIdentifier("splash_tablet",
                                "layout", cordova.getActivity().getPackageName());
                    }
                } else {
                    if (ai.screenOrientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
                        splashViewId = cordova.getActivity().getResources().getIdentifier("splash_ls", "layout",
                                cordova.getActivity().getPackageName());
                    } else {
                        splashViewId = cordova.getActivity().getResources().getIdentifier("splash", "layout",
                                cordova.getActivity().getPackageName());
                    }
                }
                LayoutInflater inflater = LayoutInflater.from(cordova.getActivity());
                splashView = inflater.inflate(splashViewId, null);

                //set the splash screen image
                //http://stackoverflow.com/questions/7776445/in-android-can-i-use-image-from-assets-in-layout-xml
                ImageView backgroundImage = (ImageView) splashView
                        .findViewById(cordova.getActivity().getResources().getIdentifier("background", "id",
                                cordova.getActivity().getPackageName()));
                backgroundImage.setImageBitmap(bm);
                ((ViewGroup) root.getParent()).addView(splashView);
                splashView.bringToFront();

                //hack to fix splash screen size when it is smaller than screen            
                ImageView splashImage = (ImageView) cordova.getActivity()
                        .findViewById(cordova.getActivity().getResources().getIdentifier("background", "id",
                                cordova.getActivity().getPackageName()));
                LayoutParams params = splashImage.getLayoutParams();
                Rect imgBounds = splashImage.getDrawable().getBounds();
                int splashHeight = params.height;
                int splashWidth = params.width;

                //make copies in case we have to switch for landscape - not sure if needed, this is a last minute hack
                int deviceWidthCopy, deviceHeightCopy;
                deviceWidthCopy = deviceWidth;
                deviceHeightCopy = deviceHeight;
                if (ai.screenOrientation == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) {
                    int temp = deviceWidthCopy;
                    deviceWidthCopy = deviceHeightCopy;
                    deviceHeightCopy = temp;
                }
                if (splashHeight < deviceHeightCopy || splashWidth < deviceWidthCopy) {
                    float scaleH = (float) deviceHeightCopy / splashHeight;
                    float scaleW = (float) deviceWidthCopy / splashWidth;
                    float scale = Math.max(scaleH, scaleW);
                    params.height *= scale;
                    params.width *= scale;
                    splashImage.setLayoutParams(params);
                }

                cordova.getActivity().setProgressBarIndeterminateVisibility(true);

            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });

}

From source file:com.rfo.basic.Web.java

@TargetApi(Build.VERSION_CODES.GINGERBREAD)
private void setOrientation(int orientation) { // Convert and apply orientation setting
    switch (orientation) {
    default://from  www . j a  v  a2  s.com
    case 1:
        orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
        break;
    case 3:
        orientation = (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD)
                ? ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
                : ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
        break;
    case 0:
        orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
        break;
    case 2:
        orientation = (Build.VERSION.SDK_INT < Build.VERSION_CODES.GINGERBREAD)
                ? ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE
                : ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
        break;
    case -1:
        orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR;
        break;
    }
    setRequestedOrientation(orientation);
}

From source file:com.undatech.opaque.RemoteCanvasActivity.java

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

    // TODO: Implement left-icon
    //requestWindowFeature(Window.FEATURE_LEFT_ICON);
    //setFeatureDrawableResource(Window.FEATURE_LEFT_ICON, R.drawable.icon); 

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);

    handler = new Handler();
    setContentView(R.layout.canvas);// w w  w. j  a  va  2s .c o m
    canvas = (RemoteCanvas) findViewById(R.id.canvas);

    Intent i = getIntent();
    String vvFileName = startSessionFromVvFile(i);
    if (vvFileName == null) {
        android.util.Log.d(TAG, "Initializing session from connection settings.");
        connection = (ConnectionSettings) i.getSerializableExtra("com.undatech.opaque.ConnectionSettings");
        canvas.initialize(connection);
    } else {
        canvas.initialize(vvFileName, connection);
    }

    canvas.setOnKeyListener(this);
    canvas.setFocusableInTouchMode(true);
    canvas.setDrawingCacheEnabled(false);

    // If rotation is disabled, fix the orientation to the current one.
    if (!connection.isRotationEnabled()) {
        int orientation = getResources().getConfiguration().orientation;
        if (orientation == Configuration.ORIENTATION_LANDSCAPE) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
        } else {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        }
    }

    // This code detects when the soft keyboard is up and sets an appropriate visibleHeight in the canvas.
    // When the keyboard is gone, it resets visibleHeight and pans zero distance to prevent us from being
    // below the desktop image (if we scrolled all the way down when the keyboard was up).
    // TODO: Move this into a separate thread, and post the visibility changes to the handler.
    //       to avoid occupying the UI thread with this.
    final View rootView = ((ViewGroup) findViewById(android.R.id.content)).getChildAt(0);
    rootView.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
        @Override
        public void onGlobalLayout() {
            Rect r = new Rect();

            rootView.getWindowVisibleDisplayFrame(r);

            // To avoid setting the visible height to a wrong value after an screen unlock event
            // (when r.bottom holds the width of the screen rather than the height due to a rotation)
            // we make sure r.top is zero (i.e. there is no notification bar and we are in full-screen mode)
            // It's a bit of a hack.
            if (r.top == 0) {
                if (canvas.myDrawable != null) {
                    canvas.setVisibleDesktopHeight(r.bottom);
                    canvas.relativePan(0, 0);
                }
            }

            // Enable/show the zoomer if the keyboard is gone, and disable/hide otherwise.
            // We detect the keyboard if more than 19% of the screen is covered.
            int offset = 0;
            int rootViewHeight = rootView.getHeight();
            if (r.bottom > rootViewHeight * 0.81) {
                offset = rootViewHeight - r.bottom;
                // Soft Kbd gone, shift the meta keys and arrows down.
                if (layoutKeys != null) {
                    layoutKeys.offsetTopAndBottom(offset);
                    keyStow.offsetTopAndBottom(offset);
                    if (prevBottomOffset != offset) {
                        setExtraKeysVisibility(View.GONE, false);
                        canvas.invalidate();
                        kbdIcon.enable();
                    }
                }
            } else {
                offset = r.bottom - rootViewHeight;
                //  Soft Kbd up, shift the meta keys and arrows up.
                if (layoutKeys != null) {
                    layoutKeys.offsetTopAndBottom(offset);
                    keyStow.offsetTopAndBottom(offset);
                    if (prevBottomOffset != offset) {
                        setExtraKeysVisibility(View.VISIBLE, true);
                        canvas.invalidate();
                        kbdIcon.hide();
                        kbdIcon.disable();
                    }
                }
            }
            setKeyStowDrawableAndVisibility();
            prevBottomOffset = offset;
        }
    });

    kbdIcon = (ZoomControls) findViewById(R.id.zoomer);
    kbdIcon.hide();
    kbdIcon.setOnZoomKeyboardClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            InputMethodManager inputMgr = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            inputMgr.toggleSoftInput(0, 0);
        }
    });

    // Initialize and define actions for on-screen keys.
    initializeOnScreenKeys();

    myVibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);

    // Initialize map from XML IDs to input handlers.
    inputHandlerIdMap = new HashMap<Integer, InputHandler>();
    inputHandlerIdMap.put(R.id.inputMethodDirectSwipePan,
            new InputHandlerDirectSwipePan(this, canvas, myVibrator));
    inputHandlerIdMap.put(R.id.inputMethodDirectDragPan,
            new InputHandlerDirectDragPan(this, canvas, myVibrator));
    inputHandlerIdMap.put(R.id.inputMethodTouchpad, new InputHandlerTouchpad(this, canvas, myVibrator));
    inputHandlerIdMap.put(R.id.inputMethodSingleHanded, new InputHandlerSingleHanded(this, canvas, myVibrator));

    android.util.Log.e(TAG, "connection.getInputMethod(): " + connection.getInputMethod());
    inputHandler = idToInputHandler(connection.getInputMethod());
}