2017-09-30 3 views
1

Der Versuch, die Ausrichtung standardmäßig auf Portrait zu setzen. Um es so zu machen, ich habe hinzugefügt:Konnte Ausrichtung nicht sperren; mögliche Lösung?

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

jedoch die App automatisch dreht, um Landscape-Modus, wenn gekippt. Darüber hinaus schaltet die App auf Landscape Modus, wenn gekippt wird, auch wenn die Ausrichtung auf Porträt nur in Telefon Settings gesperrt ist. Hier

ist die Manifest.xml Datei:

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

Was möglicherweise die Ursache sein könnte und wie dieses Problem zu beheben?

Antwort

1

hinzufügen screenOrientation = "Portrait" für jede Aktivität, etwa so:

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

Stellen Sie sicher, dass Java-Code Ausrichtung der Tätigkeit des durch Zufall nicht verändert. Configchanges setzt es nicht auf den Standard, sondern fragt das Java nach der Einstellung. Entferne diese, wenn sie nichts anderes tun. See android docs here (Suche nach "android: configChanges")

Verwandte Themen