I've tried to replicate android's stock camera rotation in flutter but to no success. Either the whole app rotates, or nothing rotates. I tried to also dig deeper into the native code, but couldn't find anything that keeps the app static, while the whole system rotates behind the scenes. The main thing I am looking for is to keep the Camera view static (landscape mode), and rotate the UI with the system depending on the device orientation.
Related
I'm trying to implement orientation change in an app with a camera.
Currently most of the Camera apps do not support device orientation. Most of them lock screen orientation in portrait mode and rotate some UI elements inside by implementing OrientationListener. But with this approach, there are problems with the system behavior: keyboard and navigation gestures remain in portrait mode, which confuses users.
However, I see completely different behavior in the latest version of the default Camera app on Samsung devices. Device orientation is no longer blocked. But the camera surface does not show any signs of orientation change.
In every camera implementation I've tried, even at best you can see some flickering on orientation changes.
My guess is that for the Samsung camera app they managed to lock the orientation of the activity content or surface without locking the system orientation change.
My question is how to achieve this behaviour?
I'm working on an app that has a Single Activity and a fullscreen Fragment in that activity that uses AR Core and inherits from Sceneform. What is a good strategy for handling orientation with AR elements? It seems that most Google produced applications that user AR (Camera Playground, Maps, Arts and Culture) lock the view to portrait when in an AR session. However, we want users to be able to interact with the view when tilted to landscape as well. That would be fine to still have it locked to portrait and the user could just tilt their phone except for the issue with Android 10 gesture navigations. If a user orients their phone in landscape (while the activity is locked to portrait), a swipe from the top of the screen (which would appear to bring up the status bar) would send an onBackPressed() which would be a big UX issue.
Have others faced this issue before? Is it possible to programmatically remove the gesture navigations? Or move them without a full config change?
I am happily using libgdx for an android game application.
At a specific point in the game, I use a FrameBuffer object to render the screen onto, and then use its attached color texture for rendering that to the screen (to be able to render a half-transparent screen with full-color rectangular zones).
The documentation for FrameBuffer says:
FrameBuffers are managed. In case of an OpenGL context loss, which only happens on Android when a user switches to another application or receives an incoming call, the framebuffer will be automatically recreated.
And that works perfectly, I can switch to other applications, put the device in sleep mode, go back to the application and everything including the framebuffer is working as usual.
The problem begins when I try and change the device's language when the application is running (using the android settings menu).
After I change the language to something else, the framebuffer attached texture becomes completely black (either the rendering to it fails or its rendering to the screen does).
The incredible thing is that, even if I restart the application (i.e. the application reaches its onDestroy() method and exits), the problem does NOT go away, and it does only when I kill the application process from the task manager.
I probably could solve this by adding a System.exit(0) inside the onDestroy() method, but does anyone have an idea about what exactly happens when I change the device language?
I cannot think of any possible relation between that and the framebuffer object state (the other textures are working as usual!), if anyone could enlight me it would be greatly appreciated.
I have recently started studying Android, and I would, as first application, create my own camera. After taking a look at the API and other examples on the internet, I was able to create a working app, however I have this problem: if I rotate the tablet that I'm using to try what I do, my app rotates in the wrong way.
So, when I switch from portrait to landscape, the transition is successful and buttons rotate correctly, but what camera really sees is as if it were rotated 90 degrees more than it should.
All this unless I decide to set in my activity screenOrientation: landscape, because in this case the camera sees everything correctly, but the buttons remain fixed in one place, don't rotate with the rotation of the tablet.
I have a tablet with only front-facing camera.
What can I do to fix the problem?
check this answer I gave some time ago, it does have a nice method to call to correctly set the camera orientation.
How can I know the position of the camera on an android device?
and with that code you should let your activity rotate freely
I know you can set orientation using android:screenOrientation statically and setRequestedOrientation programatically. However the problem is that if I use either of these to set the screen orientation I do not get to choose which landscape or which portrait I want. To wit, flipping the phone 180 degrees does not rotate the view but rather just appears upside down to the user. I cannot use screenOrientation="sensor", because in some cases I would only want the view to be landscape OR portrait and seldom both. This seems insignificant until you consider external hardware.
If I developed an app and set the layout to android:screenOrientation="landscape", the app would only display correctly if the left side of the droid were sitting on a desk. Unforunately the left side is where the usb port is, so the phone would not sit very well on that side if it were plugged in. Unless of course they used a docking station but that is not the kind of help I am looking for. If the right side of the phone is sitting on the desk to allow for the cord, the display appears upside down. I tried posting an image but being a new user I was not able to do so.
What I would like to know is how to programmatically choose which landscape (Surface.ROTATION_90,Surface.ROTATION_270) or portrait (Surface.ROTATION_0,Surface.ROTATION_180) orientation I wish the user to see, but more importantly allow them to do so in the app's settings activity. I have googled for quite awhile and all I can find are sensors that tell you when the orientation/rotation has changed and to what, but none show how to programmatically set either.