I see that is a lot of solutions related to this issue, but none of this solved my problem.
I try to read image from png file to bitmap (image is very small ~16px so there is no option that I got OutOfMemoryException) using BitmapFactory.decodeFile(path) function.
My file hierarchy is as simple as possible:
-java
--example.com.app
---MainActivity.class
-res
--drawable
---array.png
I launch application from MainActivity and on button click I try to read png image to bitmap. I try to read image to bitmap in the following ways:
String path = Uri.parse("android.resource://"+R.class.getPackage().getName() +"/drawable/arrow.png").toString(); Bitmap bitmap = BitmapFactory.decodeFile(path);String path = Uri.parse("android.resource://drawable/arrow.png").toString(); Bitmap bitmap = BitmapFactory.decodeFile(path);
Everytime bitmap is null. Do you know where could be a problem?
Android API 27