• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Tim Cooke
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • Junilu Lacar
  • Rob Spoor
  • Jeanne Boyarsky
Saloon Keepers:
  • Stephan van Hulst
  • Carey Brown
  • Tim Holloway
  • Piet Souris
Bartenders:

NullPointerException - ArrayList<URI>

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Rancher
Posts: 4936
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Rancher
Posts: 4936
38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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..
 
My pie came with a little toothpic holding up this tiny ad:
The Low Tech Laboratory Movie Kickstarter is LIVE NOW!
https://www.kickstarter.com/projects/paulwheaton/low-tech
reply
    Bookmark Topic Watch Topic
  • New Topic