forum

Home / DeveloperSection / Forums / Out of memory issue , while loading an image to a Bitmap object

Out of memory issue , while loading an image to a Bitmap object

Anonymous User 1723 21-May-2015
I have a list view with a couple of image buttons on each row. When you click the list row, it launches a new activity. I have had to build my own tabs because of an issue with the camera layout. The activity that gets launched for result is a map. If I click on my button to launch the image preview (load an image off the SD card) the application returns from the activity back to the listview activity to the result handler to relaunch my new activity which is nothing more than an image widget.

The image preview on the list view is being done with the cursor and ListAdapter. This makes it pretty simple, but I am not sure how I can put a resized image (I.e. Smaller bit size not pixel as the src for the image button on the fly. So I just resized the image that came off the phone camera.

The issue is that I get an out of memory error when it tries to go back and re-launch the 2nd activity.

** Is there a way I can build the list adapter easily row by row, where I can resize on the fly (bit wise)? This would be preferable as I also need to make some changes to the properties of the widgets/elements in each row as I am unable to select a row with touch screen because of focus issue. (I can use roller ball.)

** I know I can do an out of band resize and save of my image, but that is not really what I want to do, but some sample code for that would be nice.

As soon as I disabled the image on the list view it worked fine again.

FYI: This is how I was doing it:
String[] from = new String[] { DBHelper.KEY_BUSINESSNAME,
                               DBHelper.KEY_ADDRESS,
                               DBHelper.KEY_CITY,
                               DBHelper.KEY_GPSLONG,
                               DBHelper.KEY_GPSLAT,
                               DBHelper.KEY_IMAGEFILENAME  + ""};
int[] to = new int[] { R.id.businessname,
                       R.id.address,
                       R.id.city,
                       R.id.gpslong,
                       R.id.gpslat,
                       R.id.imagefilename };
notes = new SimpleCursorAdapter(this, R.layout.notes_row, c, from, to);
setListAdapter(notes);
Where R.id.imagefilename is a ButtonImage.

Updated on 22-May-2015
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By