银河S3 - 在纵向模式下拍照破坏活动银河、纵向、模式下

2023-09-12 22:15:12 作者:洒脱做人

所以,这个问题已经被问以多种形式对这个论坛,但没有一个答案都在帮助我。我有我只能够重现上的三星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回来。当我用相机在纵向模式下这只是发生,在横向模式下它的罚款。

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.

我用这个code启动相机:

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.

我已经看到了,建议增加机器人:configChanges =岗位定位| 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"

以清单是不够的。

to the Manifest will not be enough.

勾选此摘录的Andr​​oid文档

请注意:如果您的应用程序面向API级别13或更高版本(由的minSdkVersion和targetSdkVersion属性的声明),那么你也应该申报屏幕尺寸的配置,因为它也改变时,纵向和横向之间的设备的开关。

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.