In my app i have integrated fetching tweets from twitter..when i move to twitter fragment page and then suddenly moves to another fragment while the twitter fragment is still loading tweets then my app crashes and displays following errors..
08-30 15:17:10.273 1476-1476/com.pepup.league E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.NullPointerException
at com.pepup.league.ui.tabsswipe.adapter.TwitterAdapter.<init>(TwitterAdapter.java:45)
at com.pepup.league.ui.tabsswipe.TwitterFragment$DownloadTwitterTask.onPostExecute(TwitterFragment.java:135)
at com.pepup.league.ui.tabsswipe.TwitterFragment$DownloadTwitterTask.onPostExecute(TwitterFragment.java:77)
at android.os.AsyncTask.finish(AsyncTask.java:631)
at android.os.AsyncTask.access$600(AsyncTask.java:177)
at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:644)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:153)
at android.app.ActivityThread.main(ActivityThread.java:5086)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
at dalvik.system.NativeStart.main(Native Method)
The errors are showed in the line-
java:45
inflater = (LayoutInflater) activity.
getSystemService(Context.LAYOUT_INFLATER_SERVICE);
java:135
TwitterAdapter adapter = new TwitterAdapter(getActivity(), data, link, image, time, name, officialname);
java:77
private class DownloadTwitterTask extends AsyncTask<String, Void, String> {
If on twitter fragment page i allow it to loads tweets which take arnd 4 seconds and then move to another fragment then app doesn't crashes..it only crashes if while loading tweets i move to another fragment..I don't know how to avoid such crash...
0 comments:
Post a Comment