I have an Android mobile app and now I'm trying to run it on Android TV emulator, but it doesn't respond to screen orientation, it is always in portrait mode even though I handled it in code (it0s working both on mobile and tablet).. This is my AndroidManifest file:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="------">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.VIBRATE" />
<permission android:name="android.permission.REBOOT" />
<uses-feature
android:name="android.hardware.touchscreen"
android:required="false" />
<uses-feature
android:name="android.hardware.camera"
android:required="true" />
<application
android:name="-----"
android:allowBackup="true"
android:icon="#drawable/ic_launcher_2"
android:label="#string/app_nameMain"
android:launchMode="singleTask"
android:theme="#style/AppTheme"
tools:replace="android:label">
<activity
android:name=".activities.LauncherActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:launchMode="singleTask"
android:theme="#style/App.Theme.Translucent"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".activities.LogInActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:windowSoftInputMode="adjustPan" />
<activity
android:name=".activities.BrowserManagerActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:theme="#style/MyHomeCustomTheme"
android:windowSoftInputMode="adjustPan" />
</application>
I also tried adding this line of code but it's not helping:
<uses-feature
android:name="android.hardware.screen.portrait"
android:required="false" />
Did you have similar experience or do you have any ideas what's the problem here?
I think it is not about your application orientation configurations. Many Android-tv producers force the orientation as landscape. If you have access, you may check system properties and find about x.forceorientation:landscape and change it.
Some producers have also put a settings menu option such as System Settings > Display > Rotate.
Another way, this application can work on some devices
I had the same problem but with a real TV device - the system ignored rotation at all (everything worked fine on tablets and phones).
I found solution for my case but it can be inappropriate for you.
So, the short answer is "impossible" the long answer goes here:
Firmware for TV devices often tweaked by their manufacturers, in my case it was /system/framework/services.jar
that contained services\com\android\server\wm\WindowManagerService.java
in which the following code handled the rotation case:
if ("box".equals(SystemProperties.get("ro.target.product", "tablet"))) {
rotation = 0;
}
of course the /system/build.prop has setting ro.target.product=box, when I tried to patch this file (I had root and possibility to reflash firmware) the system went into the kind of boot loop. The parameter ro.target.product was used several times inside system applications so I think that final firmware in my case lacks some additional code to handle other target modes. Because of this I was forced to patch classes.dex directly in order to turn this checking off.
Another set of options that controls rotation are persist.demo.hdmirotates and persist.demo.hdmirotation, by default they were turned off. When I added them via the command line:
setprop persist.demo.hdmirotates true
setprop persist.demo.hdmirotation landscape
I got desired behavior: my application chooses necessary orientation and it works! In my case the rotation of TV depends upon cabling requirements, i.e. the relative position of TV and its corresponding socket outlet on the wall.
So, no free lunch :-( each device should be handled separately.
Related
I've created a hospital related app where i want to know the whether patient has visited the doctor or not, getting the location is the requirement of my app.
I've used ACCESS_COARSE_LOCATION and ACCESS_FINE_LOCATION permission in manifest. The problem is whenever application tries to get the location at run time the system prompts a security dialog which says "this app is trying to obtain your current location" and asks user to allow or deny it,, and if user clicks on the deny button the location is not fetched..
I don't want the user to click on the deny button is there any way i can skip this security dialog and set 'always allow' option in my app permission through code and get the location without ever prompting the user for access.
manifest file
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.kaizen"
android:versionCode="4"
android:versionName="1.1" >
<uses-sdk
android:minSdkVersion="11"
android:targetSdkVersion="22" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<application
android:name="com.kaizen.volley.VolleySingleton"
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.kaizen.SplashScreen"
android:configChanges="keyboardHidden"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.kaizen.Login"
android:windowSoftInputMode="stateHidden|adjustResize" />
<activity
android:name="com.kaizen.AppMenu"
android:screenOrientation="landscape"
android:windowSoftInputMode="stateHidden|adjustResize" />
<activity
android:name="com.kaizen.SignUp"
android:windowSoftInputMode="stateHidden|adjustResize" />
</application>
The dialog you're seeing surely is a vendor specific feature. E.g. there is some function called KNOX for Samsung business devices, that seems to behave like what you're seeing. Once you found out where it comes from exactly, I wouldn't care about it any further. This is not widely spread and in those cases where the message pops up it will do for a reason: the user wants (or is forced by his administrator) to be informed about certain actions, such as apps wanting to get the current location.
You may check the normal behavior of your app in an emulator, if you do not have another device.
I have followed all steps mentioned in the porting guide for V1.
<uses-feature
android:glEsVersion="0x00020000"
android:required="true" />
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<meta-data
android:name="com.here.android.maps.appid"
android:value="id here" />
<meta-data
android:name="com.here.android.maps.apptoken"
android:value="token here" />
<uses-library
android:name="com.google.android.maps"
android:required="false" />
<uses-library
android:name="com.here.android"
android:required="false" />
<activity
android:name=".ui.maps.HereLocationsActivity"
android:launchMode="singleTop"
android:hardwareAccelerated="true"
android:theme="#android:style/Theme.Holo"
android:screenOrientation="portrait" >
</activity>
I have added hardwareAcceleration to application tag as well.
It shows location markers properly without map tiles.
What could be the issuw. I am testing on a Nokia X device without SD card.
Any help would be appreciated.
the minSdkVersion should be also changed to be 11, you do need to set the Id & token to values reserved for you
As well as do add following permissions as well:
android.permission.WRITE_EXTERNAL_STORAGE
android.permission.ACCESS_WIFI_STATE
Also do try zooming out, could indeed be that you are located in a area which is shown in white and having full zoom there..
Basically it should be black if the initialization fails, and it should be blue if there is no tiles (or you are at sea), white background thus would indeed be inddicating something else going wrong.
Do also make sure you have enabled location, and have working mobile internet. Would also suggest opening HERE maps app, and downlaoding the maps tiles for the same location used in the app, thus you could see that how it is supposed to look like.
I have a weird problem. I set the screen orientation in android manifest and it works on emulater but not on the actual device. I also changed the orientation programmatically and still the problem persists. My manifest is as follows -
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.example.rotatedsignage"
android:versionCode="1"
android:versionName="1.0" xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="19" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<application
android:allowBackup="true"
android:icon="#drawable/ic_launcher"
android:label="#string/app_name"
android:theme="#style/AppTheme" >
<activity
android:name="com.example.rotatedsignage.MainActivity"
android:configChanges="orientation"
android:label="#string/app_name"
android:screenOrientation="portrait" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver
android:name="com.example.rotatedsignage.BootReceiver"
android:enabled="true"
android:exported="true" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
</intent-filter>
</receiver>
</application>
</manifest>
What is wrong with my code? The code I used -
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
any help is appreciated. Thanks in advance.
Check in your device under Settings section that whether your AutoRotate screen is locked or not.If it is locked then uncheck it.
Hope this helps.
First check your device settings as Siddharth Vyas suggest you, then make some changes like following in your config file.
<preference name="orientation" value="default" />
default means both landscape and portrait are enabled or else you can put portrait and landscape whatever you want in place of default. Hope this helps.
I restarted the app in my android phone and screen rotation started to work. I think, for a real device, if changes are made in app.json, then app needs to be restarted to see the changes.
The app i am developing should be displayed only in landscape mode.
In my app descriptor i have
<aspectRatio>landscape</aspectRatio>
<autoOrients>false</autoOrients>
On iOS devices app is launched in landscape mode and everything works as expected.
But when i tried to deploy on my android device ( Samsung galaxy S3 ), the app is launched in portrait mode.
When I modify the descriptor file to read :
<aspectRatio>landscape</aspectRatio>
<autoOrients>true</autoOrients>
then the app will be changing orientation.
While debugging i found out that the apps orientation when starting is stage.orientation == "default"
Also i have added android:screenOrientation="landscape" to android specific configurations in my app.xml (the app descriptor file):
<android>
<manifestAdditions>
<![CDATA[
<manifest android:installLocation="auto">
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.DISABLE_KEYGUARD"/>
<uses-permission android:name="android.permission.WAKE_LOCK"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-feature android:required="true" android:name="android.hardware.touchscreen.multitouch"/>
<application android:enabled="true">
<activity android:excludeFromRecents="false" android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
]]>
</manifestAdditions>
<!--Color depth for the app (either "32bit" or "16bit"). Optional. Default 16bit before namespace 3.0, 32bit after -->
<!--<colorDepth></colorDepth>-->
</android>
Is this a known issue? What could be the cause of this?
EDIT:
I ended up using stage.setAspectRatio( StageAspectRatio.LANDSCAPE ); in my main class. It will work even with devices that have default orientation other than PORTRAIT
I had similar problems with orientation. As i needed to restrict orientation change only for certain devices i solved it by setting values at runtime (before app has fully initialised).
In main application tag, listen for preinitialize event:
<s:Application ...
preinitialize="preinit()">
And set orientation values in listener:
private function preinit():void
{
systemManager.stage.setOrientation(StageOrientation.ROTATED_LEFT);
systemManager.stage.autoOrients = false;
}
Or try StageOrientation.ROTATED_RIGHT instead.
Edit: As Josh commented, this will only work for devices with portrait as the default (ie: your Samsung S3).
my android application performance is low, it takes a long startup time. i have 5 buttons, one imageview, 3 textView, 2 editText and one listView initialized in onCreate() method. Is large number of ui object the reason for slow startup?? Is there any fault in manifest.xml??
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ars.application"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="#drawable/lightvasicon" android:label="#string/app_name" android:debuggable="true">
<activity android:name=".LightVas"
android:label="#string/app_name"
android:screenOrientation="portrait"
android:configChanges="keyboardHidden|orientation" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
<uses-permission
android:name="android.permission.ACCESS_COARSE_LOCATION"></uses-permission>
<uses-permission
android:name="android.permission.ACCESS_FINE_LOCATION"></uses-permission>
<uses-permission
android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"></uses-permission>
<uses-permission
android:name="android.permission.ACCESS_MOCK_LOCATION"></uses-permission>
<uses-permission
android:name="android.permission.CONTROL_LOCATION_UPDATES"></uses-permission>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-sdk android:minSdkVersion="7" />
</manifest>
Generic performance advice:
In most cases you shouldn't try to guess what is causing performance problems as intuition is often wrong. If you knew the cause of slow code, you wouldn't have written it slow in the first place!
Use the profiler to work out where your performance problems are.
Optimize just the slow parts. Keep a copy of your traces and compare them after making a change, so you know whether you're heading in the right direction or not.
Make your own simple timing method to verify your results, this will make sure that trace recording itself is not causing performance issues in a different place.