I’m looking to change the screen orientation based on device type. The case is that our development platform is hooked via HMDI to an LCD (and is fixed), and then tested on an actual handset or tablet. I want the development platform to always appear in landscape, and everything else in portrait.
I wrote a little static method that accepts an Activity object and calls it’s setScreenOrientation if the device is a certain type. I place the call to this method in the Activitys onCreate, passing itself as the parameter. Alternately, I placed it in the onStart as well. The issue is that it’s leading to unpredictable behavior. I suspect the Activity is being restarted by the call to setRequestedOrientation. The API does state that “it is possible for the Activity to be restarted” by calling this method. Sometimes it will change orientation a few times before settling out, sometime it won’t, and it always seems to crash the application.
I guess the question becomes: How do I set the orientation for an Activity that hasn’t been started yet without using the Manifest?
Any help is appreciated.
Thanks,
Brian
You can’t set the orientation dynamically before you actually run.
If you want your orientation to vary, you should use one of the orientation modes: the default one allowing it to vary based on the device preference and how the user rotates the screen, “nosensor” to use the device’s preferred orientation without allowing it to changed based on the user rotating the screen, etc.