landscape mode in tablet only - android

My app has to support landscape/portrait mode only for tablets, phones will only support portrait mode. What is the best way to implement this?
Options that I am considering:
a) using two apk files, one for phones and one for tablets. The one for phone will lock landscape mode in the manifest
2) using one apk file. Detect that device is a phone, lock landscape mode inside each activity.
any advice will be appreciated.
Regards

You can use a SuperClass for activities and implement this https://stackoverflow.com/a/9629127/710162 on, for example, onCreate().

Related

Set system level default screen orientation for an android device

I have a project requirement to create a kiosk based application which will always be in the landscape mode,for which I am making use of a tablet running on 4.2.2.One of the modules has the functionality to make phone calls.For making the calls from my app, I invoke the default android dialer app.However,I notice that even if my device is physically in the landscape mode,at times when the default dialer app is called,it first displays its portrait layout and the quickly switches to the landscape one(which is not visually appealing).Now,since I do not have access to modify the source code of the default dialer app,I was wondering if there is a way that I can specify a system level screen orientation as landscape ?
PS: I have root access for my tablet.
Any help would be appreciated.Many thanks !
There's an app for that: Rotation Locker
You can also add the switch ro.sf.hwrotation 90 in your build.prop file

Lock screen rotation for **ALL** Android Apps on a device

this is my first post so please correct me if I do any mistake regarding rules :-)
Heres my problem:
I am trying to set a fixed screen rotation for all Apps on an Android device
(not just my App). I searched a lot but found only solutions for single Apps.
I had the following Ideas:
1) Use the API ==> seems not possible
2) Change accelerometer values ==> seems not possible
3) virtually open a hardware keyboard ==> seems not possible
Turning off autorotation keeps all Apps in portrait mode, but I would like all
Apps to be in landscape mode.
Can anybody help me please?
At least for Android 4.2. (Nexus 7) you can hold device in landscape mode and then disable autorotation. Afterwards all apps work in landscape mode.

Android - Forcing orientation in smartphones only

My app has 3 screens, and all of them must be portrait-only in smartphones and both orientation for tablets.
Unitl now I was using the following code in OnCreate:
if (!getResources().getBoolean(R.bool.isTablet)) {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
However if I hold the smartphone in landscape mode and launch the application it will show in landscape for a few seconds then rotate to portrait.
Many answers here suggest locking orientation via manifest, but that would lock the orientation in tablets, which is not desired.
I would be very grateful for any information that leads me to a solution. Thanks.
You could lock it in the Manifest and then unlock it in code if it's a tablet.
It may not matter for your case, but I've read that the Nexus 7 doesn't report itself as a tablet using the method you do. I'm not sure that's accurate though, never having tried it myself.

Air Android app crashes when phone changes orientation

... or at various settings in the app xml (<appName>-app.xml or application.xml) when holding the phone in Portrait-orientation instead of landscape-orientation.
Depending on various settings our testphone, Samsung Galaxy s3, crashes right at launch when we do debug on the phone in FlashDevelop. Actually we are debugging with a release so we don't get any traces, but all the same we are running the app on the phone.
For instance if we set
<aspectRatio>landscape</aspectRatio>
<autoOrients>true</autoOrients>
and hold the phone in landscape orientation when we start the debug, then the app runs as should be.
However if we with the same settings hold the phone in portrait orientation when starting the debug, then the app crashes on startup.
The exact same happens if we set auto orient to false and/or remove the Aspect Ratio.
It also doesn't matter what we set stage.scaleMode to in my Main class... or at least i've not been able to figure out any combo with aspectRatio/autoOrients/ that works.
I read something at a glance here at Stack Overflow in another thread about something that seemed similar was a bug in earlier Android versions, but that it should be fixed in ICS (which we have on the test devices).
And I may also have seen something at a glance about it being related to the virtual keyboard and to add some code in the xml Manifest at various actions..
Does anyone have a clue for sure please? :-)
edit:
The App is built to only ever be shown in Landscape orientation. It can't work in portrait.
I have also encountered same problem; app crashes everytime orientation changes. What I did was very simple:
FIRST, create two folders for your layout:
layout
layout-land
Then, put your portait layouts in layout and landscape layouts in layout-land.
This will do the trick. Hope you can get idea from my experience.

Dialer in landscape mode

I have written a dock app that utilizes the stock dialer within android but it always displays in portrait mode is there a snippet that I must include to get the dialer to respond to being in the dock. How do I call the layout that the stock dock program does?
Thanks in advance.
You can tell the user to put it in a dock, I suppose. If the device is in landscape mode, and the application does not support landscape mode (e.g., the dialer on my Nexus S), that is just the way it is.
More generally, you have no right to dictate how third party applications should look and behave, any more than other people have the right to dictate how your application should look and behave. The application will look and behave how its developers designed. If they have different layouts for landscape or being in some sort of dock, they will use those layouts... when they are in landscape or in some sort of dock.

Categories

Resources