根据设备传感器设置旋转,覆盖旋转锁定。

huangapple go评论67阅读模式
英文:

Set Rotation based on device sensor overriding rotation lock

问题

我一直在尝试使用ML Kit Vision快速入门示例应用来开发一个眨眼检测应用程序。
为此,我一直在使用带有CameraX库的人脸检测器模块。
在将示例应用程序安装到我的安卓手机上后,我发现将设备锁定在屏幕旋转后,该应用无法像预期那样检测到人脸。
我想知道应该如何修改代码以覆盖设备上的屏幕旋转锁定,使应用能够自动旋转其方向以检测人脸。

英文:

I have been trying to use the ML Kit Vision Quickstart Sample App to develop a blink detection app.
For this, I have been using the Face Detector module with the CameraX library.
On installing the sample app on my Android phone, I found that rotating the device with Screen Rotation locked makes the app unable to detect faces, as expected.
I want to know how I should modify the code to override the Screen Rotation lock on the device, so that the app automatically rotates its orientation to detect faces.

答案1

得分: 0

为了覆盖屏幕锁定,您可以将下一个标签添加到清单中的目标活动:

android:screenOrientation="sensor"

尽管这只会允许旋转活动,而不考虑屏幕锁定。您仍然需要处理相机代码的方向更改。我的意思是,相机镜头是固定设备,不会旋转,因此您需要通过代码处理图像旋转。

英文:

To override the screen lock you may add the next tag to your target activity in the manifest:

android:screenOrientation="sensor"

Although this will only allow to rotate the activity regardless the screen lock. You still need to handle the orientation changes for the camera code. What I mean is that your camera lens is a fixed device and it doesn't rotate, therefore you need to handle image rotation by code.

huangapple
  • 本文由 发表于 2020年10月9日 00:16:14
  • 转载请务必保留本文链接:https://go.coder-hub.com/64266602.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定