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

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

问题描述

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.

解决方案

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 mentions in the documentation

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天全站免登陆