• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps List <String> array to bundle [SOLVED]

timcs

Member
Hi

I am having problems when passing a variable defined as a List<String> data = null ; to a Bundle. I am able to do this with an Intent using ArrayListExtra (I think that is is ) but this does not work with a Bundle.

The problem is that the method I am currently using does not have a compile error but when the app is rotated the onsaveinstatancestate is where it errors.

Sorry for the vague post but I do not have the code with me at the moment.


*** EDIT 1 ****

Code I have used but although does not show as a problem when compiling but when the rotation takes place the app crashes with a java null pointer error , this is held within the onSaveInstanceState method


[HIGH] if (!exporti.isEmpty()) {

saved.putStringArrayList("DATA", (ArrayList<String>) exporti);
}

[/HIGH]


I know that this is the cause of the error because when I remove it , the error does not occur.

The variable exporti is defined as follows:

[HIGH] List<String> exporti = null;[/HIGH]



Thanks

TimCS
 
Worked this out , it was the actual IF statement that was falling over. As this variable may not have been used at this stage I did

[HIGH]if (exporti != null )[/HIGH]

Thanks

TimCS
 
Back
Top Bottom