Specifying a theme in android manifest prevents automatic screen orientation change - android

If I do not specify a theme in my android manifest, the screen automatically rotates when device changes orientation. But as soon as I specify a theme in the application or activity tags, automatic screen rotation ceases to happen. This is regardless of whether I specify a standard android theme or a custom one.
Automatic rotation happens with this:
<application android:icon="#drawable/icon" android:label="#string/app_name">
...
</application>
But not with this:
<application android:icon="#drawable/icon" android:label="#string/app_name"
android:theme="#android:style/Theme.Translucent">
...
</application>
This is on an Identity Tab and the API target is Android 2.1-update1

Problem is with the device / implementation. Tried it on a phone from a different vendor and it works.
Thanks #source.rar for the emulator clue. Since I had a device I hadn't bothered to check on the emulator.

Related

Unity3D application always launches with same orientation on Android, regardless of OS orientation

When I launches app, it always has same orientation.
After some seconds, maybe in splash scene, it turns to OS orientation.
I got that the orientation always 'Landscape Left' even if device was 'Landscape Right'.
That is my problem.
I expect that app launches so that it matches the orientation of os.
Not portrait or landscape problem, but 'Landscape Left' or 'Landscape Right' problem ;(
PlayerSettings like as bellow.
http://answers.unity3d.com/storage/temp/48453-orientation.png
I set 'Auto Rotation' and checked 'Landscape Right' and 'Landscape Left'.
http://answers.unity3d.com/storage/temp/48455-minsdk.png
And I also set min SDK api level 14.
I set screenOrientation="landscape" in AndroidManifest.xml
<activity android:name="myMainActivity" android:label="#string/app_name" android:theme="#android:style/Theme.Black.NoTitleBar.Fullscreen" android:icon="#drawable/app_icon" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen" android:screenOrientation="landscape" android:launchMode="singleTop">
Im using Unity3d 4.6.6p1
Thanks ;)
You can use this to control the orientation in the device via Code Screen.orientation.
You only need to ask wich are the current orientation and channge it to the other if you need it.
Hope It'll be helpfull to you.

My Android app rotates even if screen rotation is disabled in the OS. How can I fix this?

I am developing an Android app that has full support for landscape mode. All of my activities have the following properties set in the manifest:
android:configChanges="keyboardHidden|locale|orientation"
android:screenOrientation="sensor"
However, if I disable rotation in the phone's Screen settings, my app still rotates when the phone is rotated. This kind of bothers me; it seems like the whole point of a system-level setting is moot if it can be overriden by an individual app. How can I fix this so it follows the system-level setting while still behaving properly if screen rotation is enabled on the phone?
You could try using
android:screenOrientation="user"
You can try other way like this ,
android:screenOrientation="landscape"
android:configChanges="orientation|keyboardHidden"
apply these attributes after the activity name in AndroidManifest.xml file.
you can add android:screenOrientation="user" and make sure there is no SCREEN_ORIENTATION_SENSOR in the java code or manifest.

Can TabGroup Windows be Locked on Android?

My app has a handful of windows. After each of those windows is created, I have code whose intent is to lock those windows in portrait mode:
var win = Ti.UI.createWindow({ ... });
win.orientationModes = [ Ti.UI.PORTRAIT ];
I still can't believe that there isn't a more universal way of doing this for Android, but that's a gripe for another day. :-) For now, this is mostly working. I'm hoping someone here can help me remove the mostly qualifier.
The app opens with a tab group containing 4 tabs. If I rotate my device as soon as the default active tab is loaded, the layout rotates as well. Oops. In fact, if I go immediately to any of those tabs and rotate my device, the layout rotates. More oops.
However -- and this is the fun part -- if I relaunch the app and jump first to a secondary window, one loaded from one of the tab windows, and rotate my phone, no display rotation. Yay! Now I jump back to any of the tab windows, the ones that were rotating before, they no longer rotate.
Wat?!
That's the pattern I think I'm seeing right now. Anyone seen this before? I'm guessing that it's a tab group thing, but I don't see any orientation accessors in the API. Any guidance would be much appreciated.
Thanks.
You'll want to add this to your tiapp.xml
<android >
<manifest>
<application>
<activity android:name="org.appcelerator.titanium.TiActivity" android:screenOrientation="portrait" android:configChanges="keyboardHidden|orientation">
</activity>
</application>
</manifest>
</android>
That will lock your entire app into portrait mode
Create a custom AndroidManifest.xml through the help of this
and add this line in Application Blog
<application
android:debuggable="false"
android:icon="#drawable/appicon"
android:label="iVite"
android:name="IviteApplication" >
<activity
android:configChanges="keyboardHidden"
android:name="org.appcelerator.titanium.TiActivity"
android:screenOrientation="portrait"/>
<activity
android:configChanges="keyboardHidden"
android:name="ti.modules.titanium.ui.TiTabActivity"
android:screenOrientation="portrait"/>
<activity
android:name="ti.modules.titanium.ui.android.TiPreferencesActivity"/>
</application>
This is right way to use. Because, In Tabbar Application. We have also need to set Tabbar Activity and its orientation Setting. Like in above code In above Code.
Here, both Activity Orientation is set through AndroidManifest.xml.
TabbarActivity and Window Activity.
Cheers....

Set orientation - native camera/maps some other apps too

I am developing an application to take photos using the Android native camera and load maps, etc.
The orientation of the maps has been changing as I change it, but what I actually need is to have only landscape orientation even on native apps since my whole application is landscape-only.
But how can I set the orientation?
In the AndroidManifest.xml file you specify the acceptable orientations for your application.
To force your activity to remain in landscape mode simply include the android:screenOrientation tag in your activity's definition tag.
<activity android:name=".SomeActivity"
android:label="#string/app_name"
android:screenOrientation="landscape">

OpenGL when turning Android Phone

What is it called ( what term should i google) when flipping/tilting the phone, so that the view rotates when running android?
My (OpenGL) application crashes when I do this, are there some certain steps you should do when handling OpenGL when this occures?
Is there something else I might want to think about?
if you don't set the AndroidManifest.xml 's attributes for activities that handle their own rotations, your activity will be restarted, the GL context will be recreated, and at least, any surfaces and buffers that you were using will be invalid.
in my gles 1.1 application, I have the following in my AndroidManifest.xml, which specifies that my application activity wants to live on through keyboard and orientation configuration changes, and that the application supports any orientation, but doesn't want it to change -because I don't want to deal with reloading textures or redoing the game layout (yet)
<application android:label="#string/app_name"
android:icon="#drawable/icon"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
android:debuggable="true">
<activity android:name="MainActivity"
android:configChanges="keyboard|keyboardHidden|orientation"
android:screenOrientation="nosensor"
android:label="#string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
The problem is like the configuration change that occurs when the screen orientation change occurs. See Configuration Changes. You might want to tell Android that you will handle the orientation change yourself, via the configChanges attribute.
Some good reading: http://android-developers.blogspot.com/2010/09/one-screen-turn-deserves-another.html
You could try searching for "Screen rotation android" or "Screen rotation android OpenGL" since you're trying to do 3D. When the screen rotates the current surface gets destroyed and a new one gets created already accounting for the new screen dimensions.
I'd recommend looking into some sample code just to see the correct way to handle screen rotation, look for "ApiDemos.apk" in Android (it's open sourced by the way), specifically the ones who use GL", all of them handle screen rotation.

Categories

Resources