• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NullPointerException - ArrayList<URI>

 
L Vasquez
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to take/pick four pictures in a row and add them each to an ArrayList in order to be able to show one at a time in an ImageView. Once I take the very last picture however, I get the following exception:



The last line of my OnActivityResult is where the error occurs:
   
and my takePhotoIntent is:
   


Can anybody please help me understand why my array becomes null as soon as I take my fourth picture?
 
Norm Radder
Bartender
Posts: 1526
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Once I take the very last picture

What is different about the "last" picture?  How does the program know it is the last picture?
 
L Vasquez
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Norm Radder wrote:
Once I take the very last picture

What is different about the "last" picture?  How does the program know it is the last picture?


I simply looped the dispatchTakePictureIntent 4 times. When I run the program, it lets me take/choose 3 pictures and after the fourth it crashes.
 
L Vasquez
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Norm Radder wrote:
Once I take the very last picture

What is different about the "last" picture?  How does the program know it is the last picture?


Just tried without the loop and only taking one picture. Program crashes the same.
 
Norm Radder
Bartender
Posts: 1526
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
only taking one picture. Program crashes the same.

Are you sure you know where the NPE happens?  How many times is the onActivityResult method called?  Is there an extra call somewhere?
 
L Vasquez
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Norm Radder wrote:
after the fourth it crashes.

Does the same thing happen with  fewer or more than 4?


Happens with fewer/more (i.e. with two loops, on the second loop it crashes; with only one, it crashes on the one picture)
 
L Vasquez
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Norm Radder wrote:
Once I take the very last picture

What is different about the "last" picture?  How does the program know it is the last picture?


I moved to my onCreate method instead of instantiating it in the dispatchTakePhotoIntent method and no crash. When I do , I get array:[] printed out..
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic