Skip to content
Advertisement

Android NullPointer Attempt to invoke virtual method ‘boolean java.util.ArrayList.add(java.lang.Object)’ on a null object reference

I’m getting this error: java.lang.NullPointerException: Attempt to invoke virtual method 'boolean java.util.ArrayList.add(java.lang.Object)' on a null object reference and just to make it clear is that I know others with the same issue have asked the same question and I have read the solutions which are usually that you have to instantiate your ArrayList which however I am obviously doing but still receiving this error, so is there anyone that knows how I would be able to correct this error?

AddListActivity.java

JavaScript

Runtime error:

JavaScript

Edit:

How I send it from MainActivity.java:

JavaScript

Advertisement

Answer

Solved by using putParcelableArrayListExtra() instead of putExtra() and getParcelableArrayListExtra() instead of getParcelableExtra() since I am using an ArrayList.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement