0

currently working on an app for myself and ran into this issue, my context is clearly not null (would exit the function otherwise). I'm an android noobie so unsure what to do here.

Main Activity call to imageAdapter:

Main Activity call to imageAdapter

ImageAdapter constructor:

ImageAdapter constructor

Function throwing the error

Function throwing the error

Stacktrace

Stacktrace

Any help would be greatly appreciated!!!

2
  • Your code doesn't match your error. The mContext == null should be entered... Commented Nov 17, 2018 at 3:51
  • 1
    Please don't post screenshots of code, XML, or logcat output. Please post all text as text. Commented Nov 17, 2018 at 3:55

1 Answer 1

1

You can't use this during field initialization for the Activity because it is before the Android Activity LifeCycle, and thus the Context will be null.

Move this.imagesAdapter = new ImageAdapter(this) into onCreate

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.