• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Retrieving bitmap image from a URL ,getting nullpointerexception randomly in android

 
achuthan mukundarajan
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am doing a project with google maps in it.I am trying to retrieve bitmap images from a URL and it works fine ,but not all the time

The code i am using to retrieve the url is inside a async class.

The async class:


I am calling the async class as:



The problem is that the variable pinbit gets NPE randomly.Many times the desired result is seen.But sometimes out of random i get NPE.So i think there is something wrong with the doInBackground method where the web operation takes place.How do i ensure that the code with the web operation doesnt break?

The LOGCAT:

 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I suspect it is the "Bimap" reference assigned in line 19 rather than the one assigned in line 33 that is null, correct? The javadocs of the former say that it can be null, whereas the javadocs of the latter don't mention that.

It says: "If the input stream is null, or cannot be used to decode a bitmap, the function returns null." - not particularly helpful, unfortunately.
 
achuthan mukundarajan
Ranch Hand
Posts: 87
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So can you suggest a fix?
 
Ulf Dittmer
Rancher
Posts: 42969
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, except to try different inputs and see if you can find a pattern when it occurs, and if so, work around that. I assume you have already googled the problem.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic