@Override
public void active() {
// TODO Auto-generated method stub
int result = -1;
final MapControl mapControl = SMEnvironmentManager.getInstance().getMapView().getMapControl();
if (mapControl != null) {
Bitmap screenshotBmp = Bitmap.createBitmap(mapControl.getMapWidth(), mapControl.getMapHeight(), Config.ARGB_8888);
if (mapControl.outputMap(screenshotBmp)) {
FileOutputStream out;
try {
out = new FileOutputStream(mCacheMediaFile);
if (out != null) {
screenshotBmp.compress(Bitmap.CompressFormat.JPEG, 100, out);
out.flush();
out.close();
result = 0;// 成功
}
} catch (FileNotFoundException e) {
// // TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// // TODO Auto-generated catch block
e.printStackTrace();
}
}
}
final int successed = result;
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public void run() {
if (successed >= 0) {
Toast.makeText(AppEngine.getInstance().getCurrentContext(), "截图成功!", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(AppEngine.getInstance().getCurrentContext(), "截图失败!", Toast.LENGTH_SHORT).show();
}
dismissProgressView();
}
});
}
});
使用imobile9D 操作系统win10 AndroidStudio3.0