<?xml version="1.0" encoding="utf-8"?>
       <manifest xmlns:android="http://schemas.android.com/apk/res/android"
         package="com.example.cap_im"
         android:versionCode="1"
         android:versionName="1.0" 
       >
       <uses-permission android:name="android.permission.INTERNET" />

       <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
       <uses-permission android:name="android.permission.CAMERA"/>


       <uses-sdk
         android:targetSdkVersion="17" />

        <application
        android:icon="@drawable/ic_launcher"
         android:label="@string/app_name"
         android:theme="@style/AppTheme" >
          <activity
          android:name="com.example.cap_im.MainActivity"
          android:label="@string/app_name" >
          <intent-filter>
              <action android:name="android.intent.action.MAIN" 
               android:screenOrientation="landscape"
                />
            <category android:name="android.intent.category.LAUNCHER" />
          </intent-filter>
      </activity>
    </application>

  </manifest>

I used above code in android manifest to keep the screen always landscape mode.but it didnt work.above xml file is my manifest file.

有帮助吗?

解决方案

Just remove configchanges and set this for every activity in manifest file:

<activity android:name="MyActivity" 
 android:screenOrientation="landscape"></activity>

其他提示

In your activity tag you have write like this-

<activity android:name="MyActivity" 
android:screenOrientation="landscape"></activity>

If you want reflect this for whole app. It should be indside your each and every activity tag.

I agree with @Shani Goriwal and @Tarun Droid. But I think we also need to add the android:config for each activity:

 <activity
            android:screenOrientation="landscape"
        android:configChanges="orientation"
            android:name="com.example.cap_im.MainActivity">
 </activity>

use this on onCreateview setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top