三星Tab3上的sendUserActionEvent()mView == null [英] sendUserActionEvent() mView==null on Samsung Tab3

查看:101
本文介绍了三星Tab3上的sendUserActionEvent()mView == null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用相机从我的应用程序内部捕获图像后预览图像,我确定路径不为null,但是我在这行代码Bitmap bitmap = BitmapFactory.decodeFile(fileUri.getPath(),options);中收到此错误,并且没有图像视图.注意:我在其他设备(不是Samsung)上测试了代码,并且可以正常工作.

I am trying to preview an image after capturing it using camera from inside my app, I am sure the path is not null but I am receiving this error in this line of code Bitmap bitmap = BitmapFactory.decodeFile(fileUri.getPath(),options); and there is no image view. Note: I tested the code on another device (not Samsung) and it works.

推荐答案

我找到了解决此问题的方法.不幸的是,在某些三星设备上,内置摄像头应用程序存在问题,导致屏幕旋转,从而导致您重新开始活动.为此,mView变为空.三星的其他意图也会发生这种情况,而不仅仅是在相机中.要解决此问题,您必须在活动下的清单中添加以下行:

I found a fix for this problem. Unfortunately, on some Samsung devices there is a problem with the built-in camera app that it causes screen rotation which leads to restarting your activity. For that mView becomes null. This happens also with other intents in samsung, not only in the camera. To fix it, you have to add this line in your manifest under your activity:

android:configChanges="orientation|screenSize"

Google在文档中提及

Google mentions in the documentation

从Android 3.2(API级别13)开始,当设备在纵向和横向之间切换时,"屏幕尺寸"也会更改.因此,如果要防止在开发API级别13或更高级别(由minSdkVersion和targetSdkVersion属性声明)时由于方向更改而导致运行时重新启动,则必须在"orientation"值之外还包括"screenSize"值.也就是说,您必须声明android:configChanges="orientation|screenSize".但是,如果您的应用程序以API级别12或更低级别为目标,则您的活动始终会自行处理此配置更改(即使在Android 3.2或更高版本的设备上运行,此配置更改也不会重新启动您的活动).

Beginning with Android 3.2 (API level 13), the "screen size" also changes when the device switches between portrait and landscape orientation. Thus, if you want to prevent runtime restarts due to orientation change when developing for API level 13 or higher (as declared by the minSdkVersion and targetSdkVersion attributes), you must include the "screenSize" value in addition to the "orientation" value. That is, you must declare android:configChanges="orientation|screenSize". However, if your application targets API level 12 or lower, then your activity always handles this configuration change itself (this configuration change does not restart your activity, even when running on an Android 3.2 or higher device).

这篇关于三星Tab3上的sendUserActionEvent()mView == null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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