• Advertisement
Sign in to follow this  

Android Image Loading

This topic is 2124 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm having issues with the way that I'm loading my images in Android, this is the way I'm doing it just now.


try{
AssetManager assetManager = context.getAssets();
inputStream = assetManager.open("blackcat.png");
cat = BitmapFactory.decodeStream(inputStream);
inputStream.close();

inputStream = assetManager.open("Jellyfish1.png");
jellyfish = BitmapFactory.decodeStream(inputStream);
inputStream.close();

inputStream = assetManager.open("/Dog.png");
bigdog = BitmapFactory.decodeStream(inputStream);
inputStream.close();

inputStream = assetManager.open("exit.png");
exitTile = BitmapFactory.decodeStream(inputStream);
inputStream.close();

inputStream = assetManager.open("kitchen.png");
background = BitmapFactory.decodeStream(inputStream);
inputStream.close();

inputStream = assetManager.open("endscreen.png");
gameover = BitmapFactory.decodeStream(inputStream);
inputStream.close();
}catch(IOException ex){}


Any help would be massively appreciated as I'm pretty stuck for what to do now. Edited by styuR

Share this post


Link to post
Share on other sites
Advertisement
Is there any reason you are loading them from assets instead of resources? As I recall loading them from resources is slightly easier.

Share this post


Link to post
Share on other sites
Nope, no reason, I'm pretty inexperienced with this haha.

Share this post


Link to post
Share on other sites
If you can use resources, just load it like this:

Drawable drawable = getResources().getDrawable(R.drawable.whateveryourimageiscalled);

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement