Android Screen and Webcam

Source: Internet
Author: User

A androidmanifest.xml file setting

1. By default, the activity call is rebuilt when the screen rotates oncreate

You can add settings to the corresponding activity

android:configchanges= "orientation|screensize"//individual settings orientation may not be valid

When the screen changes, the activity is not rebuilt and the onconfigurationchanged is called.

@Override public    void onconfigurationchanged (Configuration newconfig) {        //newconfig.orientation;//get screen status        //CONFIGURATION.ORIENTATION_LANDSCAPE//2 Horizontal        //configuration.orientation_portrait//1 Vertical        Super.onconfigurationchanged (Newconfig);    }

2. Force fixed activity display direction, ignoring machine auto-rotation function

android:screenorientation= "Landscape"//Horizontal

android:screenorientation= "Portrait"//Vertical

Screenorientation a total of 7 selectable values (constants defined in the Android.content.pm.ActivityInfo Class):

Landscape: Horizontal screen (landscape photo), the width of the display is greater than the height;
Portrait: Vertical screen (portrait), the height of the display is greater than the width;
User: The current preferred direction for users;
Behind: Inherits the active direction of the activity below the activity stack;
Sensor: The physical sensor determines the direction of the display, depending on how the user holds the device, and when the device is rotated, the direction changes-between the horizontal screen and the vertical screen;
Nosensor: Ignoring physical sensors-that is, the display direction is independent of the physical sensor, no matter how the user rotates the display direction of the device will not change (except for the "unspecified" setting);
Unspecified: Unspecified, this is the default value, by the Android system to choose the appropriate direction, the selection strategy depends on the configuration of the specific device, so different devices will have a different direction choice;

Two-Write code call function
1. Force fixed activity display direction (same as setting android:screenorientation effect)

Call the Setrequestedorientation function in activity

Setrequestedorientation (Activityinfo.screen_orientation_landscape);//Cross
Setrequestedorientation (activityinfo.screen_orientation_portrait);//Vertical



this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR);

Android Screen and Webcam

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.