Xubera
Xubera

Reputation: 13

android Drawable calling NullPointerException in onCreate after onDestroy has been called

I am trying to make an App that acts as a map of a local area. Because of the local area, I do not want to use Googlemaps or its API. I want to use a .png that I import. My image is 2300 x 1650 and after searching for a way to load this image into my Activity (because just making one bitmap throws OOM exception), I found a way using Drawables. My code to implement the drawable is...

InputStream mapInput = resources.openRawResource(R.drawable.mymap);
mapDrawable = Drawable.createFromStream(mapInput, "mymap");
mapDrawable.setFilterBitmap(true);
mapDrawable.setBounds(0, 0, MAP_WIDTH, MAP_HEIGHT);
myCustomView.setMapDrawable(mapDrawable, MAP_WIDTH, MAP_HEIGHT);

and this works all fine and dandy and allows the App to function. However if I BACK or HOME screen out of the application and attempt to reload it, I get a NullPointerException when I try to access mapDrawable (so in this line of code, on mapDrawable.setFilterBitmap(true))

After my app fails, if I try to reopen it again, it works again. Unless I BACK or HOME out of it and then it fails. It always fails on the attempt to reopen.

I don't understand what I am doing wrong.

Upvotes: 0

Views: 219

Answers (1)

user647826
user647826

Reputation:

Here is a sample project showing asynchronous in google Maps..

https://github.com/commonsguy/cw-advandroid/tree/master/Maps/NooYawkAsync/

Try this if it works..

Upvotes: 2

Related Questions