Hello I have a strange bug, when I want to trigger the orientation change on the Galaxy Nexus(4.0.4), it simply doesn't jump into the onConfigurationChanged(Configuration) function.
On the HTC Desire(4.0.4) it works without any issues with the same code. And even on an emulator with 720p it works. I tried to update to Android 4.1, but I still have the same problem.
Does anyone have the same problems or any solutions?
I see both devices running Android 4.x, but try adding screenSize value as described in my earlier answer here.
In the manifest, int the <activity> tag, add android:configChanges="orientation". This tells the system that your activity will handle orientation changes by itself, hence the onConfigurationChanged() will be triggered.
screenSize flag on Android 4.X needed.
Try another android compiler builder.
If you have called setRequestedOrientation(..) in the activity before, the onConfigurationChanged(Configuration) will not be triggered by the system auto-detect of rotation.
Related
Can't seem to launch Layout Inspector on Android Studio 3.0 (Canary 3)
When connected to my device and app running, choosing Tools > Android > Layout Inspector comes up with the following error dialog:
"Error obtaining view hierarchy: Unexpected error: empty view hierarchy"
Any setup I'm missing? I have Developer Options enabled on the device.
In general I've this behavior when something is "moving" in the view so the layout inspector cannot retrieve a simple layout, that's why pausing a video will work but if you have something more complex like camera preview or Google Map is harder, not sure how to work around this
If you have ViewTreeObserver in your code to measure a view's width/height, and you're changing some width/height/padding/etc. according to a result you are getting from addOnPreDrawListener of ViewTreeObserver;
Just comment inside onPreDraw or comment all code related to ViewTreeObserver.
I can't launch my hierarchy viewer while playing video. Once I pause the video, it works!
This could be related to your Android version. For example, in my case, this error occurs on Genymotion on Android 4. After moving to Android 5 this error gone.
In my case, I had two devices connected to add, one device and an emulator. And I had to make sure only one device is connected. Then it worked. I was on Android Studio 3.2 Canary.
What I tried and did NOT work:
kill adb process and tried it again
clearing cache and restart
uninstalling the app, cleaning the build and building it again
disconnect the device and plug it back in
Finally I managed to solve it by turning off developer options and then turning it on + enable usb debugging.
Had same problem on Android Studio v2.3.3, problem was related to CountDownTimer Object, somehow it cause problem (probably because of onTick method).
After commenting it, I could normally use Layout Inspector.
Maybe you use something similar in your code, try to comment it out and see if if works.
Had the same problem.
Could not capture hierarchy on Emulator.
I used a real device and it worked fine.
I changed my device from a Nexus 6 to a Pixel XL. Then it worked.
So try and change your device and see if that fixes the issue.
I have just imported Android's BluetoothChat example into Eclipse. In the Android manifest, I can see that the option android:configChanges="orientation" was already there. However, when I tested the app on two real phones, the connection was always lost whenever I rotated the screen.
In another thread, a user reported that the connection was not lost when the android:configChanges="orientation" option was there, but this is not what I have experienced.
The only modification I have made to the code is to add the line
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
right after super.onCreate() in the onCreate() method. This change was made to fix a null pointer exception and I don't think it has anything to do with the screen rotation problem. Does anyone know what is the cause of lost connections and how to fix the issue?
Can you try this one? Should be able to do the trick.
android:configChanges="orientation|screensize"
Caution: Beginning with Android 3.2 (API level 13), the "screen size"
also changes when the device switches between portrait and landscape
orientation. Thus, if you want to prevent runtime restarts due to
orientation change when developing for API level 13 or higher (as
declared by the minSdkVersion and targetSdkVersion attributes), you
must include the "screenSize" value in addition to the "orientation"
value. That is, you must decalare
android:configChanges="orientation|screenSize".
From http://developer.android.com/guide/topics/resources/runtime-changes.html
I want my application to work in Portrait & reversePortrait mode .. In other words, I want it to work in portrait and make it rotatable 180 degrees!
I'm using the following code within <activity> tag of the MainActivity in the Manifest.
android:screenOrientation="sensorPortrait"
However, this seems to work only on Android 4.1.2 and backward.
It doesn't work on Android 4.2.2 and above!
I tried on different phones, the same result! How to solve it?
I'm aware of a typo error by Google that replaced sensorPortrait by sensorPortait at some point.
Not sure if that is your case, but depending on your targetApi, it might.
Use sensorPortait and see what happens at compilation.
This has been fixed in API 16.
I'm currently developing an application with which a schedule can be retrieved and viewed. To display the schedule I used the TimeRulerView (and BlocksLayout and BlockView) java source files from the Google IO 2011 app because I liked the look and feel. Source code can be found here: https://github.com/underhilllabs/iosched2011 . (Google replaced there one with the code of IO2012).
Since my Galaxy Nexus updated tot Jelly Bean (4.1.1) yesterday the TimeRulerView (and/or one of the others) doesn't get shown anymore.
The weird thing is that they are actually still there, but there not visible. I can see a scrollbar of the length the timeruler normally has. Also when I normally click on an block in the view I get a little pop-up, and this still happens when not seeing the timeruler or a block.
I tested the original IO2011 app on my JB GN but nothing is visible there either, so the problem lies within (one of) the view(s) or the way JellyBean is rendering the view(s) (project butter maybe?).
See here ( https://dl.dropbox.com/u/7102660/TimeRulerView_JellyBean_problem.zip ) for screenshots on ICS (app working), JB (app not working) and the GoogleIO2011 app.
Could this be something to do with Hardware acceleration? I just recently ran into an issue on couple phones with ICS, but not all phones/devices were affected. Adding the hardwareAccelerated tag to my manifest didn't fix the issue either, and I had to define it on specific views that I did not want to be hardware accelerate. My solution used android:layerType="software" in my xml layouts and setLayerType(LAYER_TYPE_SOFTWARE, null) in the java code.
EDIT: Testing this more, it didn't fix my issue using setLayerType on Jelly Bean. Setting the layer type to software on ICS did fix my issue. The only way I could make the views show up was setting the whole application or specific activity to android:hardwareAccelerated="false".
Thanks to Chris answer I played around with hardware acceleration settings. I use the iosched2011 code as well and only had to remove the line android:layerType="software" from my BlocksLayout View inside the block_content.xml file .
Actually my problem is the same as the question posted in :
the same problem
But there is no answer yet..
Here is the problem I got :
I've just built an application using sencha touch & phone gap. It runs well on my galaxy tab but when I rotate it to portrait or landscape, it is going crash.
I have added :
android:configChanges="orientation|keyboardHidden"
on my manifest file but it is still going crash when I rotate it.
I don't know how could this happen.
Could someone help me?
Note :
I'm using
- Galaxy tab
- Sencha-touch 1.1
- Phone gap 1.2
You should have
android:configChanges="keyboardHidden|orientation|screenLayout"
instead of
android:configChanges="orientation|keyboardHidden"
to your activity in the manifest
Might be a bit late... but since I've recently been trying this, I found that specifying
android:configChanges="orientation|screenSize|keyboardHidden"
works where as
android:configChanges="keyboardHidden|orientation|screenLayout"
does NOT.
I'm using cordova 2.0.0.