1

the question might be a bit obvious, but here is the situation:

In my app (googleMaps v2) i have a custom marker which has an image view (image taken from camera intent). So i have saved all the information needed to load the image again once the app restarts in SQlite database. But the problem is when trying to load the image into the Layout inflater nothing is displayed, however when i create an Imageview within my activity (ie not in a layout inflater) then the image is displayed, but obviously over the map which i don't want.

So here is my code for loading the image in the ImageView When returning from the camera intent (this works)

@Override
  public View getInfoContents(Marker marker)
    {
  View v  = getLayoutInflater().inflate(R.layout.infowindow_layout, null);
  ImageView markerIcon = (ImageView) v.findViewById(R.id.PicView);
Bitmap bitmap = myMarkersHash.get(marker.getId());
markerIcon.setImageBitmap(bitmap);

Then when trying to load from the database as the app restarts:

filep = arg1.getString(arg1.getColumnIndex(LocationsDB.FIELD_FILEPATH));
....
View view  = getLayoutInflater().inflate(R.layout.infowindow_layout, null);
ImageView image = (ImageView) view.findViewById(R.id.PicView);
Bitmap myImage = BitmapFactory.decodeFile(filep);
image.setImageBitmap(myImage);

then nothing is displayed

Could anyone tell me why the image doesn't display? PS there is no error messages or anything that i can add to this question.

Newbie
  • 177
  • 12

1 Answers1

0

If you are storing the file path in filep, then should it be:

Bitmap myImage = BitmapFactory.decodeFile(filep);

In response to my comment below, you may try adding the configuration option ARGB_8888 to preserve the file, such as:

filep = arg1.getString(arg1.getColumnIndex(LocationsDB.FIELD_FILEPATH));
....
View view  = getLayoutInflater().inflate(R.layout.infowindow_layout, null);
ImageView image = (ImageView) view.findViewById(R.id.PicView);
BitmapFactory.Options options = new BitmapFactory.Options();
options.inPreferredConfig = Bitmap.Config.ARGB_8888;
Bitmap myImage = BitmapFactory.decodeFile(filep, options);
image.setImageBitmap(myImage);
Edward Bagby
  • 825
  • 7
  • 22
  • Sorry my bad it was a typo, i have changed the code a bit, but still displays nothing. – Newbie Jan 11 '15 at 17:13
  • Apparently, others have had problems when pulling from SD cards, if that's the case in your app. See this post: http://stackoverflow.com/questions/8710515/reading-an-image-file-into-bitmap-from-sdcard-why-am-i-getting-a-nullpointerexc – Edward Bagby Jan 11 '15 at 17:18
  • Thanks, but the problem is the image is displayed when i use Imageview within the same XML layout as google map, but when i use the layout inflater the image isn't displayed. – Newbie Jan 11 '15 at 17:48