sendUserActionEvent() mView==null on Samsung Tab3

烈酒焚心 提交于 2019-11-28 11:39:15
KyleCrowley

In regards to the sendUserActionEvent() mView==null, it is a know bug with Samsung devices (see this and this).

If it works on non-Samsung devices, then it is not your fault, it is Samsung's.
However, you should try and find a workaround if you can.
Again, it isn't your fault, it is a bug with TouchWiz.

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

I have struggled with this error for days, this happens because Samsung Camera app is by default in Landscape mode.

If you start camera app from an activity in Portrait mode, when it comes back from Landscape it calls automatically again OnCreate, that's why your path is null.

I solved this by adding a static counter into the activity if it is equal to 0 app call oncreate and did it all, if it is greater than 0 loads only layout.

Bhrigu

Yes, that's correct.

What AJ has mentioned is the solution:

android:configChanges="orientation|screenSize"

It also solves another issue that arises due to calling the OnCreateView method every time the phone is rotated; helps prevent different edit fields from reverting to their original values, provided you have used onSaveInstance() to store your initial values. You can refer to this video here for that-

https://www.youtube.com/watch?v=_K_qlNluW38&index=67&list=PLHs_NFdr_LaHmEh7hV-wPyS-gKnAVPzBU

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!