I want to get image in my bitmap like this :
bitmap = BitmapFactory.decodeResource(getResources(), R.drawable.bug);
but this show me error on R.drawable.bug that bug can not be resolve or is not a field please tell where I'm doing things wrong.
Do you have a bug graphic file present in the drawable folder?
Have you tried to clean your project in order for R.drawable to be correctly generated?
Try this:
InputStream is = getResources().openRawResource(R.drawable.bug);
Bitmap pisc = BitmapFactory.decodeStream(new BufferedInputStream(is));
Just copy Your Drawable in all the drawable folders in your project. like this drawable-hdpi drawable-ldpi drawable-mdpi
来源:https://stackoverflow.com/questions/15220767/bitmapfactory-decoderesource-does-not-get-my-image-from-drawable