You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
java.lang.NullPointerException:
at helper.UserAccount.getToken (UserAccount.java:40)
at helper.CourseRequestHandler.getCourseData (CourseRequestHandler.java:166)
at crux.bphc.cms.fragments.MyCoursesFragment.updateCourseContent (MyCoursesFragment.java:283)
at crux.bphc.cms.fragments.MyCoursesFragment.access$400 (MyCoursesFragment.java:46)
at crux.bphc.cms.fragments.MyCoursesFragment$5.onResponse (MyCoursesFragment.java:258)
at crux.bphc.cms.fragments.MyCoursesFragment$5.onResponse (MyCoursesFragment.java:251)
at helper.CourseRequestHandler$1.onResponse (CourseRequestHandler.java:92)
at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall$1$1.run (ExecutorCallAdapterFactory.java:70)
at android.os.Handler.handleCallback (Handler.java:883)
at android.os.Handler.dispatchMessage (Handler.java:100)
at android.os.Looper.loop (Looper.java:214)
at android.app.ActivityThread.main (ActivityThread.java:7695)
at java.lang.reflect.Method.invoke (Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:516)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:950)
At MyCoursesFragment.java:279, a new CourseRequestsHandler instance is being created, which requires a Context. It's probable that by the time the the method is called, the Activity dies for whatever reason. There are two ways to deal with this:
Refactor the fragment (and similar fragments) to use a single CourseRequestHandler, created when the fragment is created. Cache any information instead of instantiating SharedPreferences in UserAccount's getters everytime.
Use an Application context instead of an Activity context inside UserAccount.
Initial impressesions: I think both of them should be done. A refactor of CourseRequestHandler (if need be) might be beneficial. And, an Application context is enough for SharedPreference. It isn't required to couple that with a particular activity.
The text was updated successfully, but these errors were encountered:
Here is the error log from
v1.6.0
:At
MyCoursesFragment.java:279
, a newCourseRequestsHandler
instance is being created, which requires aContext
. It's probable that by the time the the method is called, the Activity dies for whatever reason. There are two ways to deal with this:CourseRequestHandler
, created when the fragment is created. Cache any information instead of instantiatingSharedPreferences
inUserAccount
's getters everytime.UserAccount
.Initial impressesions: I think both of them should be done. A refactor of
CourseRequestHandler
(if need be) might be beneficial. And, an Application context is enough forSharedPreference
. It isn't required to couple that with a particular activity.The text was updated successfully, but these errors were encountered: