gpt4 book ai didi

android - 三星 Tab3 上的 sendUserActionEvent() mView==null

转载 作者:塔克拉玛干 更新时间:2023-11-03 00:38:10 26 4
gpt4 key购买 nike

我试图在我的应用程序内部使用相机捕获图像后预览图像,我确定路径不为空,但我在这行代码中收到此错误 Bitmap bitmap = BitmapFactory.decodeFile(fileUri .getPath(),options); 并且没有 ImageView 。注意:我在另一台设备(不是三星)上测试了代码并且它有效。

最佳答案

我找到了解决这个问题的方法。不幸的是,在某些三星设备上,内置相机应用程序存在问题,它会导致屏幕旋转,从而导致您重新启动 Activity 。因为 mView 变为空。三星的其他 Intent 也会发生这种情况,而不仅仅是相机。要修复它,您必须在 list 中的 Activity 下添加这一行:

android:configChanges="orientation|screenSize"

Google 在 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).

关于android - 三星 Tab3 上的 sendUserActionEvent() mView==null,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23016155/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com