• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to pass a growing array to onSaveInstanceState

 
L Vasquez
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I take the 4 pictures (see the loop in dispatchTakePhotoIntent) and add each to the Uri Arraylist (see last line in onActivityResult); the array comes back to me blank. I was wondering if this has to do with the rotating screen when taking a picture (the program is in landscape). I understand that onSaveInstanceState could fix this. How do I pass the ArrayList<Uri> to the saveInstanceState?


and my takePhotoIntent is:
   
 
Brian Tkatch
Bartender
Posts: 567
25
Linux Notepad Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
onSaveInstanceState() uses a Bundle object to store data, and that Bundle is sent to OnRestoreInstanceState(). The Bundle has the appropriate methods to store and retrieve an array.
 
L Vasquez
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Brian Tkatch wrote:onSaveInstanceState() uses a Bundle object to store data, and that Bundle is sent to OnRestoreInstanceState(). The Bundle has the appropriate methods to store and retrieve an array.


But how about an ArrayList of URIs specifically?
 
Brian Tkatch
Bartender
Posts: 567
25
Linux Notepad Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
L Vasquez wrote:But how about an ArrayList of URIs specifically?

Isn't that parceable? If so, you can use putParcelableArrayList().
 
L Vasquez
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Brian Tkatch wrote:
L Vasquez wrote:But how about an ArrayList of URIs specifically?

Isn't that parceable? If so, you can use putParcelableArrayList().


Just like this?

 
Brian Tkatch
Bartender
Posts: 567
25
Linux Notepad Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
L Vasquez wrote:Just like this?


I admit my lack of knowledge here. That definitely looks right though. Now, grab the Bundle from onRestore... and see if you get the array.

Oh, and i don't know if it matters, but i'd put the super first.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic