Copy link to clipboard
Copied
Hi,
Has anyone else had the problem of the kindle fire HD orientation being upside down when auto orientation is turned on for landscape? Is there anyway to fix it?
Yes. Also, the original Kindle Fire had the same issue, but for a different reason. There are various works arounds to the issue, but most of those have serious possible side effects. Here’s a description of the general problem:
If the user holds the Kindle Fire the correct way up (either the USB connector is to the right if there is no camera, or the camera is at the top or left if there is a camera), everything works ok.
If the user is holding it the other way up (by the way, I’m just describing
...Copy link to clipboard
Copied
Yes. Also, the original Kindle Fire had the same issue, but for a different reason. There are various works arounds to the issue, but most of those have serious possible side effects. Here’s a description of the general problem:
If the user holds the Kindle Fire the correct way up (either the USB connector is to the right if there is no camera, or the camera is at the top or left if there is a camera), everything works ok.
If the user is holding it the other way up (by the way, I’m just describing landscape here), then on the original Kindle Fire it may work, but on the new ones it will be upside down.
If you do a fix for that, the app will be correct, but if the user turns the device at all, the app becomes upside down, and remains that way until they force quit.
So, after a lot of attempted fixes the only way I found to make it predictable was to turn off auto rotation and to also do a work around for the initial incorrectness.
Now, because the original Kindle Fire has the opposite issue to the later ones, I have to work around its issues in the opposite way. Which means finding a way to detect an old Kindle Fire versus a newer one. One way to do that is to check the screen size.
No other Android device has these issues, so you have to tell whether you should be attempting the work around at all. I use a variable that tells me that the app was bought n the Amazon Appstore for that. If it was, I do the Kindle Fire work arounds. If it wasn’t, I don’t.
The final work around code is like this (the timer is used because at first the orientation may return "unknown"):
private var screenwidth: int = Math.max(Capabilities.screenResolutionX, Capabilities.screenResolutionY);
private var screenheight: int = Math.min(Capabilities.screenResolutionX, Capabilities.screenResolutionY);
private var store:String = "amazon";//amazon or empty;
private var fixtimer:Timer = new Timer(10,200);
if(store=="amazon"){
fixtimer.addEventListener(TimerEvent.TIMER,fixrot);
fixtimer.start();
}
private function fixrot(e: TimerEvent) {
if (stage.deviceOrientation != "unknown") {
fixtimer.stop();
fixtimer.removeEventListener(TimerEvent.TIMER, fixrot);
} else {
return;
}
var oldkindle: Boolean = false;
if (screenwidth == 1024 && screenheight == 600) oldkindle = true;
if (!oldkindle) {
if (stage.deviceOrientation == "rotatedLeft") {
stage.setOrientation("rotatedLeft");
}
} else {
if (stage.deviceOrientation == "rotatedRight") {
stage.setOrientation("rotatedLeft");
} else {
if (stage.deviceOrientation == "rotatedLeft") {
stage.setOrientation("rotatedRight");
}
}
}
}
Copy link to clipboard
Copied
Thanks Colin. To be on the safe side I'm just going to turn auto orientation off.
Copy link to clipboard
Copied
I may not have made it clear, I also turn off auto orientation as part of the fix. Even with that off you have to work around the upside down app problem.
Copy link to clipboard
Copied
Colin,
I am having the exact problem described in here. In my case, I locked my aspect ratio to landscape and turned off auto orientation. The video was still upside down even after I applied your code. I was wondering maybe there was a flaw in your logics, so I opposited the "oldkindle" variable, nothing changed. Could you please confirm if you tried it on the kindle fire and the code above is correct.
Many thanks,
Yu
Copy link to clipboard
Copied
How are you playing the video? I haven't played video in Flash on Kindle Fire. Are your other graphics the right way up?
Copy link to clipboard
Copied
I am writing the live video app using Camera api. Here is how I get the camera.
Camera.getCamera();
Once I get the default camera, I attach the camera to a spark videodisplay to play back to the user.
As with my tests, the app shipped with kindle is fine, and a free app called "funtastic camera" works fine too.
Copy link to clipboard
Copied
Is the rest of your app the right way up? My fixes were just for the main app, it’s quite possible the camera needs its own set of fixes.
Copy link to clipboard
Copied
Thanks a lot for the helps. I did not have any issues with other parts of the app.
But I think that finally I found a solution. I just need to rotate the videodisplay to 180 degree. unfortuantely, I have to inform all the parties of receivers to rotate too.
But your kindle detection idea is great. I am thinking that maybe I should go further to write ane to get the manufacturer or mode information so I do not need to delopy it to amazon store.
Copy link to clipboard
Copied
Colin - so to your knowledge there is no identifier (e.g. OS string or something in Capabilities) that is unique to Kindle Fire (I don't have one for testing) that we can hack into without havingto go native, as benjik suggests? Also - just wondering if you use a string (like 'store' in your example) or if you actually use compiler constants, which would be nicer
Copy link to clipboard
Copied
When I first had to distinguish Kindle Fire (in that case it was because it claims to have camera when it doesn’t really), I might have checked that the Android version was 2.3.4. But with there being so many models now I can’t be sure what Android version would show up.
Although it is possible to buy Android apps for Kindle Fire from Google Play, I guess, it’s only Amazon testers who would reject the app if the user has to turn the device around. So, just doing the test based on the store is an easy way to only fix things for those devices. Now, I suppose that if a non-Kindle Fire user decided to buy one of my apps from the Amazon Appstore, there’s a chance that I might accidentally invert the app on startup. But that’s not likely for my landscape apps, because most Android tablets refer to that orientation as Default, and Kindle Fire sees it as rotatedLeft or rotatedRight. So, worth the risk.
As for compiler directives, I’m publishing to three or four stores, and having a single variable seems easier than four sets of directives, along with the multiple lines of duplicate code for each of the compile cases.
Copy link to clipboard
Copied
Cheers Colin. I just meant using a string-type compiler constant - just wondered if you used those rather than const defined in code, or if there was a reason not to?
Copy link to clipboard
Copied
Hi Colin, is this IF necessary? I don't know if it was a typo, or if doesn't need to be there:
if (stage.deviceOrientation == "rotatedLeft") {
stage.setOrientation("rotatedLeft");
}
It looks like one of them should be right instead of left, because with these lines inside the if(!oldKindle) means that there's not any change for the new kindle (HD).
Copy link to clipboard
Copied
Yes, part of the problem is that the stage orientation claimed by the new Kindle Fire is incorrect, it’s really the opposite at the time, but when told to go to that orientation it does the right thing. Even with auto orientation turned off, and the work around in place, the new Kindle Fires open with the status bar upside down. Hopefully by the time the app is loaded the screen is the right way up, but if it’s not it does so as soon as that line is reached.
Copy link to clipboard
Copied
Thanks for you answer Colin. Anyway I have a problem with this, the game never rotates, if I want to rotate the device 180 degrees, it doesn't work.
Im making some tests setting autoOrients to true, and using the event StageOrientationEvent.ORIENTATION_CHANGE to know when the device is rotating, so I can set the proper value (left or right) to avoid the bug.
Let me know if you already have a solution for that or if your code should be working fine and Im missing something.
Copy link to clipboard
Copied
I could only solve the bigger problems by turning off auto orientation. It means that the user has to continue to use the app in the orientation they were at the time they started the app. Most times that would be what they would want, only a user who starts the app, then decide they want to hold the tablet the other way up, would have a problem.
Auto orientation is a require of the iOS store, but not the Android stores.
Copy link to clipboard
Copied
Thank's for the headstart on this Colin, I ran into this myself, and think I found a proper workaround.
We can use the /system/build.props file to check whether it's a newer kindle device, and then apply the fix:
if(Capabilities.manufacturer.toLowerCase().indexOf("android") > -1){ var applyRotationFix:Boolean = false; //Use build.props file to check if we're on a problematic Kindle Device var file:File = new File("/system/build.prop"); if(file.exists){ var fs: FileStream = new FileStream(); fs.open(file, FileMode.READ); var props:String = fs.readUTFBytes(fs.bytesAvailable); fs.close(); var regExp:RegExp = /ro.product.model=(\w+)/; var model:String = props.match(regExp)? props.match(regExp).pop() : null; var targetModels:Array = ["KFAPWA", "KFAPWI", "KFTHWA", "KFTHWI", "KFSOWI"]; if(targetModels.indexOf(model) != -1){ applyRotationFix = true; } } //If we are on a problem device, apply fix: if(applyRotationFix){ var currentOrientation:String; setInterval(function(){ //If we've already forced this orientation, we don't need to do it again. if(stage.deviceOrientation == currentOrientation){ return; } //Force stage orientation to match device if(stage.deviceOrientation == StageOrientation.ROTATED_LEFT){ stage.setOrientation(StageOrientation.ROTATED_LEFT); } else if(stage.deviceOrientation == StageOrientation.ROTATED_RIGHT){ stage.setOrientation(StageOrientation.ROTATED_RIGHT); } currentOrientation = stage.deviceOrientation; }, 1000); } }
The problem seems to be that the stage thinks it's in the proper orientation, but it's not. So each time you switch, you just need to call setOrientation() oncee to force the proper switch,
GIST Here: https://gist.github.com/esDotDev/9241796
Copy link to clipboard
Copied
Thanks a lot for the fix.
I did find the same issue on these devices :
- KFJWA
- KFJWI
- KFTT
I have included them in targetModels and they seem to work fine on these devices (i don't have KFJWI but assuming its the same as KFJWA).
It seems that the only devices which don't need this fix are KFOT and Kindle Fire because these devices used to have reversed angles for left and right orientation.
Copy link to clipboard
Copied
Actually I had the same issue, it is hard to test on an Android device, you need an Kindle in order to test it.
the following code fix the issue in all Kindle's , Just create a version for Kindle and add the code below:
var cOrientation:String;
setInterval(function(){
//If we've already forced this orientation, we don't need to do it again.
if(stage.deviceOrientation == cOrientation){ return; }
//Force stage orientation to match device
if(stage.deviceOrientation == StageOrientation.ROTATED_LEFT){
stage.setOrientation(StageOrientation.ROTATED_LEFT);
}
else if(stage.deviceOrientation == StageOrientation.ROTATED_RIGHT){
stage.setOrientation(StageOrientation.ROTATED_RIGHT);
}
cOrientation = stage.deviceOrientation;
}, 1000);
This has fix the issue on two of my apps on Kindle, AirportBoard and Boongo
http://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Dmobile-apps&field-keywords=airportboard
Copy link to clipboard
Copied
Thanks, I may try that.
Copy link to clipboard
Copied
This is a real pain for non programers . I just bought my wife a Fire 8 tablet and she won't use it because the after market case handle is on the wrong side. Thus, her game is upside down in portrait and too hard to hold. I changed this one to use Google Play store apps...I just unloaded the Amazon app for "Parlor" and reinstalled from Playstore, still flips to opposite 180 😞
I can live with it, but she will not give up her old Samsung and the Fire is now just for guests 😞
I took around in Linx, but I do not know programming so this is a royal pain.
Seems like the code in the Fire is an Anazon issue, btw both apps were from their store.
I cannot just flip the case, because sadly the speakers would be covered 😞
Turning off auto rotate is irrelevant to our issue.
Good luck.
Dave
Find more inspiration, events, and resources on the new Adobe Community
Explore Now