I have an Activity which contains a MapFragment V2 on half of the screen, and on the other half there are some more views such as TextViews with details.
This how the screen looks like:
Now, I want to take a snapshot of the whole activity include the MapFragment but when I try to do that, I do get an image but the map part is blank (totally black)!
This is the code I am using for taking the screenshot and it works great!
I do know about the option to take a snapshot of the MapFragment but it takes only the map area without the rest of the screen. Something like this:
GoogleMap.SnapshotReadyCallback callback = new GoogleMap.SnapshotReadyCallback() {
@Override
public void onSnapshotReady(Bitmap snapshot) {
// TODO Auto-generated method stub
FileOutputStream out = null;
boolean status = true;
try {
out = new FileOutputStream(sharedImage);
snapshot = Bitmap.createScaledBitmap(snapshot, findViewById(R.id.trip_map).getWidth(),
findViewById(R.id.trip_map).getHeight(), true);
status = snapshot.compress(Bitmap.CompressFormat.JPEG, 100, out);
Toast.makeText(TripDetailsActivity.this, "save status: " + status, Toast.LENGTH_SHORT).show();
snapshot.recycle();
snapshot = null;
System.gc();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
out.flush();
out.close();
} catch (Exception e) {
e.printStackTrace();
}
}
openShareImageDialog(sharedImage);
}
};
mMap.snapshot(callback);
}
return true;
}
Does anyone have an idea how can I take the whole screen snapshot when there is a MapFragment there?