Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-7892] Android: Ti.Gesture.orientationchange event only fires once

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionCannot Reproduce
Resolution Date2013-02-28T09:34:12.000+0000
Affected Version/sRelease 1.8.2
Fix Version/sRelease 3.0.2
ComponentsAndroid
Labelsn/a
ReporterArthur Evans
Assigneejithinpv
Created2012-03-06T00:16:47.000+0000
Updated2017-03-07T23:54:06.000+0000

Description

Not sure if this is Emulator-specific or not. When running the code below in the emulator, the first time I rotate the device (Ctrl+F11), I see the label change to show the current orientation. However, subsequent rotations produce no update to the label. Also, the whole app seems to get stuck in the first orientation it switches into, such as landscape left.
var win1 = Titanium.UI.createWindow({  
    title:'Tab 1',
    backgroundColor:'#fff', 
    orientationModes: [ ],
    modal: true,
    navBarHidden: true,
    exitOnClose: true

});

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);
win1.open();
Ti.Gesture.addEventListener('orientationchange', function(e) {
	label1.text = "Orientation is: " + getOrientation(Ti.Gesture.orientation) + 
		"\nWindow.orientation is: " + getOrientation(win1.orientation);
	Ti.API.info("Got orientation change event.");
});


function getOrientation(o) {
    switch (o) {
        case Titanium.UI.PORTRAIT:
            return 'portrait';
        case Titanium.UI.UPSIDE_PORTRAIT:
            return 'upside portrait';
        case Titanium.UI.LANDSCAPE_LEFT:
            return 'landscape left';
        case Titanium.UI.LANDSCAPE_RIGHT:
            return 'landscape right';
        case Titanium.UI.FACE_UP:
            return 'face up';
        case Titanium.UI.FACE_DOWN:
            return 'face down';
        case Titanium.UI.UNKNOWN:
            return 'unknown';
        default:
            return 'constant not recognized';
    }
}

Comments

  1. Davide Cassenti 2012-07-02

    The code works well on a real device, while it is buggy using the Android Emulator. Tested with SDK 2.0.1 and above.
  2. jithinpv 2013-02-28

    Issue does not reproduces with Titanium Studio, build: 3.0.1.201212181159 Titanium SDK version: 3.1.0 (03/11/13 15:43 0c88429) Titanium SDK version: 3.0.2 (02/07/13 16:46 a4def81) Device: Samsung galaxy s duos Android version: 4.0.4 Emulator: Android version: 2.2
  3. Lee Morris 2017-03-07

    Closing ticket as the issue cannot be reproduced.

JSON Source