I'm a beginner android programmer and want to implement a list with RecyclerView
that can hold any media.
If size of image that is loading in my app is large I want to make it smaller. For that I found some code:
Bitmap bitmap = BitmapFactory.decodeFile(path);
Bitmap smallerBitmap = ThumbnailUtils.extractThumbnail(bitmap, bitmap.getWidth() / 8, bitmap.getHeight() / 8));
In first line I'm reading an image in my phone and in second line making it smaller. For writing it I use this part of code:
try (FileOutputStream out = new FileOutputStream(finalMyFile)) {
smallerBitmap.compress(Bitmap.CompressFormat.JPEG, 80, out);
} catch (IOException e) {
e.printStackTrace();
}
These two processes for large images need about 100 MB
memory in ram for about 1-2 seconds. But my problem is here that sometimes after end of these processes memory releases and sometimes not releases.
I did this process in many ways but my problem didn't solved. I did it with Handler
or Thread
.
My application has no problem and continue working but I don't like this for my app.
Do you have any idea?