Domanda

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

È stato utile?

Soluzione

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

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

Altri suggerimenti

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);

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top