The requestScreenshot code is still there - i.e DebugMapActivity.java:
Code:
@Override
public void onMapRegionChanged(SKCoordinateRegion skCoordinateRegion) {
if (DebugSettings.currentSettings != null && DebugSettings.currentSettings instanceof MapStateDebugSettings) {
((MapStateDebugSettings) DebugSettings.currentSettings).update();
}
if (DebugSettings.currentSettings != null && DebugSettings.currentSettings instanceof ScreenshotDebugSettings &&
((ScreenshotDebugSettings) DebugSettings.currentSettings).isContinuousScreenshotOn()) {
mapView.requestScreenshot();
}
}
How to use it:
Code:
private void testScreenshot() {
mapView.setDrawingCacheBackgroundColor(Color.TRANSPARENT);
mapView.requestScreenshot();
synchronized (mapView) {
mapView.requestRender();
try {
mapView.wait();
Bitmap mapBitmap = mapView.getScreenshot();
String filename = "/storage/sdcard0/captures/" + new SimpleDateFormat("hh:mm:ss").format(new Date()) + ".png";
FileOutputStream out = null;
try {
out = new FileOutputStream(filename);
mapBitmap.compress(Bitmap.CompressFormat.PNG, 100, out);
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if (out != null) {
out.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
} catch (final InterruptedException e) {
e.printStackTrace();
}
}
}
Bookmarks