I have an aplication in which I fill a listview from database (greendao). I have screen orientation support, so it works in both orientations. The problem I have is that when app is the background for a longer period of time (cant find some certain point when this happens) and I go back to it, the listview is empty and it crashes if I try to do anything.
I am having an impossible time debugging this since it happens only when application is in the background for some time.
I fill the listview by filling an arraylist from database and then sending it to the adapter.
Does anyone have an idea why this is happening?
EDIT: broadcast reciver problem solved
But the reason why listviews are empty is still not found.
I got another logcat tho (the problem is getting data from database :/ ):
11-11 13:45:31.136: E/AndroidRuntime(4468): FATAL EXCEPTION: main
11-11 13:45:31.136: E/AndroidRuntime(4468): java.lang.NullPointerException
11-11 13:45:31.136: E/AndroidRuntime(4468): at si.comtron.tronpos.content.DatabaseHelpers.viewArticleWithPrice(DatabaseHelpers.java:70)
11-11 13:45:31.136: E/AndroidRuntime(4468): at si.comtron.tronpos.ArticlesFragment.onCreateView(ArticlesFragment.java:269)
11-11 13:45:31.136: E/AndroidRuntime(4468): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:831)
11-11 13:45:31.136: E/AndroidRuntime(4468): at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1037)
11-11 13:45:31.136: E/AndroidRuntime(4468): at android.app.BackStackRecord.run(BackStackRecord.java:635)
11-11 13:45:31.136: E/AndroidRuntime(4468): at android.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1399)
11-11 13:45:31.136: E/AndroidRuntime(4468): at android.app.FragmentManagerImpl$1.run(FragmentManager.java:428)
11-11 13:45:31.136: E/AndroidRuntime(4468): at android.os.Handler.handleCallback(Handler.java:615)
11-11 13:45:31.136: E/AndroidRuntime(4468): at android.os.Handler.dispatchMessage(Handler.java:92)
11-11 13:45:31.136: E/AndroidRuntime(4468): at android.os.Looper.loop(Looper.java:155)
11-11 13:45:31.136: E/AndroidRuntime(4468): at android.app.ActivityThread.main(ActivityThread.java:5511)
11-11 13:45:31.136: E/AndroidRuntime(4468): at java.lang.reflect.Method.invokeNative(Native Method)
11-11 13:45:31.136: E/AndroidRuntime(4468): at java.lang.reflect.Method.invoke(Method.java:511)
11-11 13:45:31.136: E/AndroidRuntime(4468): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1029)
11-11 13:45:31.136: E/AndroidRuntime(4468): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:796)
11-11 13:45:31.136: E/AndroidRuntime(4468): at dalvik.system.NativeStart.main(Native Method)
It seems you are using
BroadcastReceiver
Unregister your receiver in
onPause()
: