掲示板
Going back from Fragment throwing NullPointerException
8年前 に Harish Kumar によって更新されました。
Going back from Fragment throwing NullPointerException
Expert 投稿: 483 参加年月日: 10/07/31 最新の投稿
Hi,
We are using custom class extending BaseListScreenlet in fragment. List is displaying fine with content. But when we move to other fragment and come back to same fragment again by using back button, we are getting NullPointerException
Any pointers would be really helpful. Please let me know if more details needed.
Regards,
Harish
We are using custom class extending BaseListScreenlet in fragment. List is displaying fine with content. But when we move to other fragment and come back to same fragment again by using back button, we are getting NullPointerException
FATAL EXCEPTION: main
PID: 26822
java.lang.NullPointerException: Attempt to get length of null array
at com.liferay.mobile.screens.base.BaseScreenlet.onRestoreInstanceState(BaseScreenlet.java:199)
at android.view.View.dispatchRestoreInstanceState(View.java:14746)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3121)
at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:3127)
at android.view.View.restoreHierarchyState(View.java:14724)
at android.support.v4.app.Fragment.restoreViewState(Fragment.java:468)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1094)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1248)
at android.support.v4.app.BackStackRecord.popFromBackStack(BackStackRecord.java:958)
at android.support.v4.app.FragmentManagerImpl.popBackStackState(FragmentManager.java:1666)
at android.support.v4.app.FragmentManagerImpl$2.run(FragmentManager.java:577)
at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1613)
at android.support.v4.app.FragmentManagerImpl$1.run(FragmentManager.java:517)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5417)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
Any pointers would be really helpful. Please let me know if more details needed.
Regards,
Harish
8年前 に Javier Gamarra によって更新されました。
RE: Going back from Fragment throwing NullPointerException
Expert 投稿: 348 参加年月日: 15/02/12 最新の投稿
Whops... checking it right now. Thanks for the call
I'll post my findings here.
I'll post my findings here.
8年前 に Javier Gamarra によって更新されました。
RE: Going back from Fragment throwing NullPointerException
Expert 投稿: 348 参加年月日: 15/02/12 最新の投稿
Uhm... I've tried to reproduce it in this branch: commit where I render a fragment showing the asset list, then a specific asset. I can go back fine.
Can you share me the list code? or paste the most relevant bits? It could happen because several things, a bug/strange behaviour in one mobile phone/brand in particular, something missing when overriding the list screenlet and a bug with a specific flow (of course!).
It seeems that the screenlet is trying to restore the screenlet state but it can't because it wasn't saved at all... that's strange... I can add a null code check to guard but every call to onRestore should have had a previous call to onSave... do you have transparencies or visible layers?
Thanks
Can you share me the list code? or paste the most relevant bits? It could happen because several things, a bug/strange behaviour in one mobile phone/brand in particular, something missing when overriding the list screenlet and a bug with a specific flow (of course!).
It seeems that the screenlet is trying to restore the screenlet state but it can't because it wasn't saved at all... that's strange... I can add a null code check to guard but every call to onRestore should have had a previous call to onSave... do you have transparencies or visible layers?
Thanks
8年前 に Harish Kumar によって更新されました。
RE: Going back from Fragment throwing NullPointerException
Expert 投稿: 483 参加年月日: 10/07/31 最新の投稿
Hi Javier,
Thanks for your response. Please find below some environment details and attached code fragments
Liferay 6.2
Liferay Screens 1.3.0
AVD Nexus_5_API_23X86
If you need more details kindly let me know.
Regards,
Harish
Thanks for your response. Please find below some environment details and attached code fragments
Liferay 6.2
Liferay Screens 1.3.0
AVD Nexus_5_API_23X86
If you need more details kindly let me know.
Regards,
Harish
8年前 に Javier Gamarra によって更新されました。
RE: Going back from Fragment throwing NullPointerException
Expert 投稿: 348 参加年月日: 15/02/12 最新の投稿
Argh... can't reproduce
Can you check out this branch? or test the APK attached?
I've copied your code and adapted to do a petition against an asset and then redirect to another screenlet (login). I've tried to go back, home, stop the application with a Nexus 5 23...
Can send me the full example (and I'll query assets instead of your values) to javier.gamarra at liferay.com ?
I can write defensive code as a bugfix but I want to know why the state is not saving correctly...
Can you check out this branch? or test the APK attached?
I've copied your code and adapted to do a petition against an asset and then redirect to another screenlet (login). I've tried to go back, home, stop the application with a Nexus 5 23...
Can send me the full example (and I'll query assets instead of your values) to javier.gamarra at liferay.com ?
I can write defensive code as a bugfix but I want to know why the state is not saving correctly...
添付ファイル:
8年前 に Harish Kumar によって更新されました。
RE: Going back from Fragment throwing NullPointerException
Expert 投稿: 483 参加年月日: 10/07/31 最新の投稿
Hi Javier,
Sent you an email with complete code.
Regards,
Harish
Sent you an email with complete code.
Regards,
Harish
8年前 に Javier Gamarra によって更新されました。
RE: Going back from Fragment throwing NullPointerException
Expert 投稿: 348 参加年月日: 15/02/12 最新の投稿
Yes, I saw it, just answered it
8年前 に Harish Kumar によって更新されました。
RE: Going back from Fragment throwing NullPointerException
Expert 投稿: 483 参加年月日: 10/07/31 最新の投稿
Your code changes worked for us. Thanks for your support.