Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-5002] Android: setting android:screenOrientation for an activity in AndroidManifest.xml does not work

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionCannot Reproduce
Resolution Date2012-02-10T00:33:26.000+0000
Affected Version/sRelease 1.7.2, Release 1.8.0.1
Fix Version/sn/a
ComponentsAndroid
Labelsqe-testadded, regression
ReporterJon Alter
AssigneeOpie Cyrus
Created2011-08-15T08:49:10.000+0000
Updated2012-02-10T00:33:26.000+0000

Description

setting android:screenOrientation for an activity in AndroidManifest.xml does not work with 1.7.2 but it does with 1.6.2 Step 1: run the code below Step 2: use a custom AndroidManifest.xml (documented in the wiki) Step 3: add android:screenOrientation="portrait" to the TiTabActivity in the AndroidManifest.xml
<activity android:name="ti.modules.titanium.ui.TiTabActivity"
			android:screenOrientation="portrait"
			android:configChanges="keyboardHidden|orientation" />
Step 4: launch the app Step 5: rotate the device Step 6: notice that the tabGroup does not rotate if you run this in 1.6.2 but it does rotate in 1.7.2
var tabGroup = Titanium.UI.createTabGroup();

var win1 = Titanium.UI.createWindow({  
    title:'Tab 1',
    backgroundColor:'#fff'
});
var tab1 = Titanium.UI.createTab({  
    icon:'KS_nav_views.png',
    title:'Tab 1',
    window:win1
});
var label1 = Titanium.UI.createLabel({
	color:'#999',
	text:'I am Window 1',
	font:{fontSize:20,fontFamily:'Helvetica Neue'},
	textAlign:'center',
	width:'auto'
});

win1.add(label1);

var win2 = Titanium.UI.createWindow({  
    title:'Tab 2',
    backgroundColor:'#fff'
});
var tab2 = Titanium.UI.createTab({  
    icon:'KS_nav_ui.png',
    title:'Tab 2',
    window:win2
});
var label2 = Titanium.UI.createLabel({
	color:'#999',
	text:'I am Window 2',
	font:{fontSize:20,fontFamily:'Helvetica Neue'},
	textAlign:'center',
	width:'auto'
});
win2.add(label2);

tabGroup.addTab(tab1);  
tabGroup.addTab(tab2);  

tabGroup.open();

Workaround

Use the orientationModes property of window
win2.orientationModes = [
			Titanium.UI.PORTRAIT
		]; 

Associated Helpdesk Ticket

http://appc.me/c/APP-688371

Attachments

FileDateSize
TiTest.zip2011-09-07T12:37:47.000+00007935433

Comments

  1. Jon Alter 2011-08-15

    Tried removing android:configChanges="keyboardHidden|orientation" from the tag. It had no affect on the rotation not working.
       <activity android:name="ti.modules.titanium.ui.TiTabActivity"
       			android:screenOrientation="portrait"
       	/>
       
  2. Opie Cyrus 2011-09-07

    Attaching test app that shows overriding the orientation mode in the tiapp.xml
  3. Wilson Luu 2011-12-19

    Reopening bug. Bug persists on: SDK build: 1.8.0.1.RC3 Runtime: V8, Rhino Titanium Studio, build: 1.0.7.201112152014 Device: Android Emulator 2.2, Nexus One (2.2.2) OS: Mac OS X Lion Note: To test the custom AndroidManifest: 1. Create a *platform* folder at the same level as Resource 2. Create an *android* folder in the *platform* folder 3. Add the AndroidManifest.xml to the *android* folder
  4. Opie Cyrus 2012-01-03

    Unable to reproduce the issue against 1.9.0 with the following AndroidManifest.xml put in the platform/android location.
       <?xml version="1.0" encoding="utf-8"?>
       <manifest xmlns:android="http://schemas.android.com/apk/res/android"
       	package="com.appcelerator.test" android:versionCode="1"
       	android:versionName="1">
       	<uses-sdk android:minSdkVersion="8" />
       
       	<application android:icon="@drawable/appicon"
       		android:label="test" android:name="TestApplication"
       		android:debuggable="false">
       
       		<activity android:name=".TestActivity"
       			android:label="test" android:theme="@style/Theme.Titanium"
       			android:configChanges="keyboardHidden|orientation">
       			<intent-filter>
       				<action android:name="android.intent.action.MAIN" />
       				<category android:name="android.intent.category.LAUNCHER" />
       			</intent-filter>
       		</activity>
       
       		
       
       		<activity android:name="org.appcelerator.titanium.TiActivity"
       			android:configChanges="keyboardHidden|orientation" />
       		<activity android:name="org.appcelerator.titanium.TiTranslucentActivity"
       			android:configChanges="keyboardHidden|orientation"
       			android:theme="@android:style/Theme.Translucent" />
       		<activity android:name="org.appcelerator.titanium.TiModalActivity"
       			android:configChanges="keyboardHidden|orientation"
       			android:theme="@android:style/Theme.Translucent" />
       		<activity android:name="ti.modules.titanium.ui.TiTabActivity"
       			android:screenOrientation="landscape" 
       			android:configChanges="keyboardHidden|orientation" />
       		<activity android:name="ti.modules.titanium.ui.android.TiPreferencesActivity" />
       
       		<service android:name="org.appcelerator.titanium.analytics.TiAnalyticsService"
       			android:exported="false" />
       		
       
       	</application>
       
       	<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
       	<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
       	<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
       	<uses-permission android:name="android.permission.INTERNET"/>
       	
       
       </manifest>
       
  5. Benjamin Jeanjean 2012-01-23

    This works with 1.9.0 but not 1.7.5 Just tested with your AndroidManifest.xml Opie.
  6. Thomas Huelbert 2012-02-09

    closing as we are not able to reproduce using master (1.9.0 Feb 9 2012 09:46 rd47ce8a4). fix will not be seen in 1.7.X branches

JSON Source