如何在没有加速度传感器的情况下启动相机意图?
我目前正在编写一个需要捕获一些图像的应用程序。我使用这样的意图启动相机应用程序:
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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您最好的选择是创建自己的相机应用程序(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())
使用 setDisplayOrientation (int Degrees) 它将使得 <
如果您使用自己的相机,则可以像这样使用它
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
http://code.google.com/p/android/issues/detail?id=1193#c42