Open PaulGene opened 5 years ago
I am using:
@Override public void onSensorChanged(SensorEvent event) { if(mView == null) return; loadNewSensorData(event); // this should not be done on the gui thread //NME.onDeviceOrientationUpdate(prepareDeviceOrientation()); final int _orientation = prepareDeviceOrientation(); if(orientation != _orientation){ orientation = _orientation; mView.queueEvent(new Runnable(){ public void run(){ if(mView != null) mView.HandleResult(NME.onDeviceOrientationUpdate(_orientation)); } }); } }
Works well for me. Would be great implement related event: https://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/StageOrientationEvent.html This could help with preventing stage orientation changing when we need: "The orientationChanging (StageOrientationEvent.ORIENTATION_CHANGING), is dispatched before the screen changes to a new orientation. Calling the preventDefault() method of the event object dispatched for orientationChanging prevents the stage from changing orientation."
Uncommenting this line fixes it https://github.com/haxenme/nme/blob/master/templates/android/java/org/haxe/nme/GameActivity.java#L1039
I know it says it shouldn't be done in the GUI thread but surely it's better than breaking functionality ?