2017-09-30 1 views
1

Essayant de définir l'orientation sur Portrait uniquement par défaut. Pour le rendre, je l'ai ajouté:Impossible de verrouiller l'orientation; solution possible?

android:configChanges="orientation" 
android:screenOrientation="portrait" 

Cependant, l'auto application tourne en mode Landscape lorsqu'il est incliné. En outre, l'application passe au mode Landscape lorsqu'elle est inclinée même lorsque l'orientation est verrouillée sur portrait uniquement dans le téléphone Settings.

Voici le fichier Manifest.xml:

<?xml version="1.0" encoding="utf-8"?> 
    <manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    package="com.browser.codedady"> 

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> 
    <uses-permission android:name="com.android.launcher.permission.INSTALL_SHORTCUT" /> 
    <uses-permission android:name="android.permission.INTERNET" /> 
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> 
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> 

    <application 
     android:allowBackup="true" 
     android:fullBackupContent="true" 
     android:icon="@mipmap/ic_launcher" 
     android:label="@string/app_name" 
     android:theme="@style/AppTheme" 
     tools:ignore="GoogleAppIndexingWarning"> 

     <!-- Browser Main Tab --> 

     <activity 
      android:name=".Activity_Main" 
      android:configChanges="orientation" 
      android:screenOrientation="portrait" 
      android:label="@string/app_name" 
      android:launchMode="singleInstance"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

       <category android:name="android.intent.category.LAUNCHER" /> 

       <action android:name="readLater" /> 
       <action android:name="bookmarks" /> 
       <action android:name="history" /> 
       <action android:name="pass" /> 
      </intent-filter> 
      <intent-filter 
       android:icon="@mipmap/ic_launcher" 
       android:label="@string/app_websearch"> 
       <action android:name="android.intent.action.SEND" /> 

       <category android:name="android.intent.category.DEFAULT" /> 

       <data android:mimeType="text/plain" /> 
      </intent-filter> 

      <meta-data 
       android:name="android.app.shortcuts" 
       android:resource="@xml/shortcuts" /> 
     </activity> 

     <!-- Other activities --> 

     <activity 
      android:name=".about.About_activity" 
      android:configChanges="orientation|screenSize" 
      android:launchMode="singleInstance" /> 
     <activity 
      android:name=".helper.Activity_intro" 
      android:configChanges="orientation|screenSize" 
      android:launchMode="singleInstance" /> 
     <activity 
      android:name=".helper.Activity_settings" 
      android:configChanges="orientation|screenSize" 
      android:launchMode="singleInstance" /> 
     <activity 
      android:name=".helper.Activity_settings_app" 
      android:configChanges="orientation|screenSize" 
      android:launchMode="singleInstance" /> 
     <activity 
      android:name=".helper.Activity_settings_data" 
      android:configChanges="orientation|screenSize" 
      android:launchMode="singleInstance" /> 
     <activity 
      android:name=".helper.Activity_settings_searchMain" 
      android:configChanges="orientation|screenSize" 
      android:launchMode="singleInstance" /> 
     <activity 
      android:name=".helper.Activity_settings_close" 
      android:configChanges="orientation|screenSize" 
      android:launchMode="singleInstance" /> 
     <activity 
      android:name=".helper.Activity_settings_start" 
      android:configChanges="orientation|screenSize" 
      android:launchMode="singleInstance" /> 
     <activity 
      android:name=".helper.Activity_settings_search" 
      android:configChanges="orientation|screenSize" 
      android:launchMode="singleInstance" /> 

     <!-- Intents --> 

     <activity 
      android:name=".helper.Activity_intent" 
      android:label="@string/app_name" 
      android:noHistory="true" 
      android:screenOrientation="portrait" 
      android:theme="@android:style/Theme.Translucent.NoTitleBar"> 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 
      </intent-filter> 
      <intent-filter> 
       <category android:name="android.intent.category.DEFAULT" /> 
       <category android:name="android.intent.category.BROWSABLE" /> 

       <action android:name="android.intent.action.VIEW" /> 

       <data android:scheme="http" /> 
       <data android:scheme="https" /> 
      </intent-filter> 
     </activity> 

     <!-- More stuff --> 

     <provider 
      android:name="android.support.v4.content.FileProvider" 
      android:authorities="com.browser.codedady.provider" 
      android:exported="false" 
      android:grantUriPermissions="true"> 
      <meta-data 
       android:name="android.support.FILE_PROVIDER_PATHS" 
       android:resource="@xml/file_paths" /> 
     </provider> 

     <activity 
      android:name=".Home" 
      android:label="@string/title_activity_home" 
      android:theme="@style/AppTheme" /> 

    </application> 

</manifest> 

Ce qui pourrait être la cause et comment résoudre ce problème?

Répondre

1

Ajouter screenOrientation = "portrait" à chaque activité, comme suit:

<activity 
     android:name=".MainActivity" 
     android:screenOrientation="portrait" /> 

Assurez-vous que votre code Java ne modifie pas l'orientation de l'activité par accident. Configchanges ne le définit pas par défaut, il demande au Java de le définir. Enlevez-les s'ils ne font rien d'autre. See android docs here (chercher "android: configChanges")