rodders1991 / SoundCloud

0 stars 0 forks source link

Defect: Images causing Memory Crash #1

Closed rodders1991 closed 8 years ago

rodders1991 commented 8 years ago

PROBLEM

Setting more than one image causes the app to crash. This is because the images are too large.

POSSIBLE SOLUTION

Using BitmapFactory you can re-size the image to stop it from causing a memory outage check out this link http://developer.android.com/training/displaying-bitmaps/load-bitmap.html for more information.

FURTHER INVESTIGATION

The example on the above URL uses decodeResources, because the image is not part of the app we have to use decodeFile. However decodeFile requires an absolute file path as a parameter. This URL http://stackoverflow.com/questions/8885204/how-to-get-the-file-path-from-uri , describes how to get an absolute path from a URI as below:

File myFile = new File(uri.getPath()); myFile.getAbsolutePath();

Then we use:

decodeFile (String pathName, BitmapFactory.Options opts)

rodders1991 commented 8 years ago

Completed and pushed into master