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

标签 android bitmap samsung-mobile

我试图在我的应用程序内部使用相机捕获图像后预览图像,我确定路径不为空,但我在这行代码中收到此错误 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/

相关文章:

android - 在android中将图像转换为位图

java - 从错误中恢复的最佳策略是什么——忽略发生错误的记录

android - 改造 : How to make XML request and get back JSON response

java - ListView 中的自定义字体

android - 无法使用 Ant 构建 Android 应用程序(同时引用 ActionBarSherlock 和 ViewPagerTabs)

Android,结果的startActivity产生奇怪的流程

android位图getPixel

dll - 如何在 F# 源文件 (fs) 中引用 system.drawing。它适用于脚本文件 (fsx)

css - Galaxy Note 4 CSS 像素

android-6.0-marshmallow - 三星 android 6.0 如何获取带有 sim 插槽 ID 的双 SIM 卡通话记录?