문제

      <?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