Galaxy S3 - 以人像模式拍照会破坏活动 [英] Galaxy S3 - taking picture in portrait mode destroys activity

查看:25
本文介绍了Galaxy S3 - 以人像模式拍照会破坏活动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以,这个问题已经在这个论坛上以多种形式提出,但没有一个答案对我有帮助.我有一个只能在三星 Galaxy S3 上重现的错误.

So, this question has been asked in many forms on this forum but none of the answers are helping me. I have a bug which I've only been able to reproduce on the Samsung Galaxy S3.

我想简单地使用手机的相机拍摄并存储一张照片,但在我收到 onActivityResult 的回复之前,我的 Activity 已被销毁.只有当我在纵向模式下使用相机时才会发生这种情况,在横向模式下就可以了.

I want to simply take and store a photo using the phone's camera, but my Activity is being destroyed before I ever hear back from onActivityResult. This ONLY happens when I use the camera in portrait mode, in landscape mode it's fine.

我正在使用此代码启动相机:

I'm using this code to launch the camera:

Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(intent, Config.ACTIVITY_TAKE_PHOTO);

在纵向模式下,我从来没有看到对 onActivityResult 的调用(来自相机活动),我只看到在我的启动活动中调用了 onDestroy().日志中没有异常或错误,也没有明显的错误导致它崩溃.

In portrait mode, I never see a call to onActivityResult (from the Camera activity), I just see an onDestroy() called in my launching activity. There are no exceptions or errors in the log, and nothing obviously wrong to make it crash.

我看到一些帖子建议将android:configChanges="orientation|keyboardHidden"" 添加到清单中,并做很多其他事情来管理使用相机时发生的方向变化,但到目前为止没有任何帮助.

I've seen posts that recommend adding "android:configChanges="orientation|keyboardHidden"" to the Manifest, and doing lots of other things to manage the orientation change that occurs when using the camera, but nothing has helped so far.

其他人解决了这个问题吗?

Has anyone else solved this problem?

推荐答案

如果您的目标超出 API 级别 13,添加

If you are targeting beyond API level 13, Adding

android:configChanges="orientation|keyboardHidden"

到 Manifest 是不够的.

to the Manifest will not be enough.

Android 文档

注意:如果您的应用程序以 API 级别 13 或更高级别为目标(由 minSdkVersion 和 targetSdkVersion 属性声明),那么您还应该声明screenSize"配置,因为当设备在纵向和横向之间切换时它也会改变.

Note: If your application targets API level 13 or higher (as declared by the minSdkVersion and targetSdkVersion attributes), then you should also declare the "screenSize" configuration, because it also changes when a device switches between portrait and landscape orientations.

因此尝试添加

android:configChanges="orientation|keyboardHidden|screenSize"

到您的清单文件.这应该可以解决您的问题.

to your Manifest file. This should solve your problem.

这篇关于Galaxy S3 - 以人像模式拍照会破坏活动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆