GooglePlayServices的最新版本(12)包含用于截屏地图的文档(https://developers.google.com/maps/documentation/android/releases#august_2013)。这是我尝试的代码,我仍然得到一个黑屏:
public void captureMapScreen() {
SnapshotReadyCallback callback = new SnapshotReadyCallback() {
Bitmap bitmap;
@Override
public void onSnapshotReady(Bitmap snapshot) {
bitmap = snapshot;
try {
FileOutputStream out = new FileOutputStream("/mnt/sdcard/" + "MyMapScreen" +
System.currentTimeMillis() + ".png");
// above "/mnt ..... png" => is a storage path (where image will be stored) + name of image you can
// customize as per your Requirement
bitmap.compress(Bitmap.CompressFormat.PNG, 90, out);
} catch (Exception e) {
e.printStackTrace();
}
}
};
GoogleMap googleMap = getMap();
googleMap.snapshot(callback);
}