如何在没有加速度传感器的情况下启动相机意图?

发布于 2024-12-28 08:50:45 字数 456 浏览 6 评论 0原文

我目前正在编写一个需要捕获一些图像的应用程序。我使用这样的意图启动相机应用程序:

if (v.equals(btnCap)) {
        Intent cameraIntent = new Intent(
                android.provider.MediaStore.ACTION_IMAGE_CAPTURE);

        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
        startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
    }

问题是:当我倾斜设备时,相机上的按钮仍然会改变方向,并且我收到的图片不是纵向的。

有谁知道如何在纵向模式下拍摄图像,即使设备倾斜?

提前致谢, 阿德里安

I'm currently writing a application that needs to capture some images. I start the camera application using a intent like this:

if (v.equals(btnCap)) {
        Intent cameraIntent = new Intent(
                android.provider.MediaStore.ACTION_IMAGE_CAPTURE);

        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
        startActivityForResult(cameraIntent, CAMERA_PIC_REQUEST);
    }

The problem is: When i tilt my device, the buttons on the camera still change their orientation and the picture I receive is not in portrait.

Does anyone know how to capture a image in portrait mode, even if the device is tilted?

Thanks in advance,
Adrian

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

潦草背影 2025-01-04 08:50:45

您最好的选择是创建自己的相机应用程序(http:// /developer.android.com/guide/topics/media/camera.html#custom-camera)。

然后,在 AndroidManifest.xml 中,在 Activity 声明中添加 android:screenOrientation="portrait" 选项。

最好构建您自己的相机活动,因为根据设备型号,您可能会遇到获取照片的问题。我曾经遇到过三星设备的问题(请参阅Android Samsung:相机应用程序获胜不返回intent.getData())

You best option is to create your own camera app (http://developer.android.com/guide/topics/media/camera.html#custom-camera).

And then, in your AndroidManifest.xml, add the android:screenOrientation="portrait" option on the declaration of your activity.

It's better to build your own camera activity, because you can have issues for getting the pictures depending on the device model. I once had an issue with Samsung devices (see Android Samsung: Camera app won't return intent.getData())

握住我的手 2025-01-04 08:50:45

使用 setDisplayOrientation (int Degrees) 它将使得 <

如果您使用自己的相机,则可以像这样使用它

camera.setDisplayOrientation(90);

a href="http://code.google.com/p/android/issues/detail?id=1193#c42" rel="nofollow">http://code.google.com/p/android/issues/detail?id=1193#c42

use setDisplayOrientation (int degrees) it will make the job

if you are using you own camera you can use it like this

camera.setDisplayOrientation(90);

http://code.google.com/p/android/issues/detail?id=1193#c42

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文