question

rkarthik83 avatar image
rkarthik83 asked

Kindle Fire Orientation Issue

I'm developing an app for Kindle Fire HD 7 inch and 10 inch tablet. I want to restrict the orientation of 7 inch to portrait and 10 inch to landscape. I setting the setRequestedOrientation in onCreate method of the activity. I'm seeing a weird issue when I hold the 7 inch tablet in landscape orientation and open the application. App initially opens in landscape mode and switches to portrait(expected orientation for 7 inch tablet) instead of opening in portrait orientation. This happens only in Kindle HD and not seeing the orientation switching behavior in any other device. Please help me in this issue. Here is the sample code setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT); Note: If I mention the screenOrientation in the menifest file it works fine but I can't as the same app should support different orientation on different sizes of the device.
fire tablet
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Sujoy@Amazon avatar image
Sujoy@Amazon answered
Hi Rkarthik83, Thank you for your post. Since you are setting the orientation in run time dynamically, the app would start with the orientation currently device has and then while the setRequestedOrientation() would be executed, the app would change the orientation. There would be a significant delay between the app starts and the above method gets executed. So you should experience the same as you have mentioned in your post. Could you tell me in which device you have seen different behavior? I have checked it amazon and non amazon devices. And both worked in the same way.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

rkarthik83 avatar image
rkarthik83 answered
Thanks Sujan, I'm not seeing orientation swift in other devices like Samsung S3, Nexus 7 Inch tablet, Nexus 10 inch tablet, etc... I would say almost on all non kindle devices.
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Bipin@Amazon avatar image
Bipin@Amazon answered
I think , you can use the below two scenario and customize it accordingly to your needs. First get which device it is: Log.i("test",("android.os.Build.DEVICE: " + android.os.Build.DEVICE)); Log.i("test",("android.os.Build.MODEL: " + android.os.Build.MODEL)); Log.i("test",("android.os.Build.PRODUCT: " + android.os.Build.PRODUCT)); Log.i("test",("android.os.Build.VERSION.CODENAME: " + android.os.Build.VERSION.CODENAME)); Log.i("test",("android.os.Build.VERSION.INCREMENTAL: " + android.os.Build.VERSION.INCREMENTAL)); Log.i("test",("android.os.Build.VERSION.RELEASE: " + android.os.Build.VERSION.RELEASE)); Log.i("test",("android.os.Build.VERSION.SDK: " + android.os.Build.VERSION.SDK)); Log.i("test",("android.os.Build.VERSION.SDK_INT: " + String.valueOf(android.os.Build.VERSION.SDK_INT))); Secondly: In onCreate method use switch case, Load the layout according to your needs. switch (getResources().getConfiguration().orientation){ case Configuration.ORIENTATION_PORTRAIT: setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); setContentView(R.layout.portrait); break; case Configuration.ORIENTATION_LANDSCAPE: setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); setContentView(R.layout.landscape); break; }
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.