好日子的家伙,我在eclipse上以编程方式进行屏幕截图,但它很成功,但谷歌地图片段只在我的屏幕捕获结果上显示黑页。我该怎么做才能在我的屏幕上显示地图?
这是我的代码:
public void download (View v){
View view = findViewById(R.id.layout_id);
view.setDrawingCacheEnabled(true);
Bitmap bitmap = view.getDrawingCache();
BitmapDrawable bitmapDrawable = new BitmapDrawable(bitmap);
//ImageView iv = (ImageView) findViewById(R.id.imageView1);
FrameLayout iv = (FrameLayout)findViewById(R.id.map);
//iv.setBackgroundDrawable(bitmapDrawable);
if (Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
//we check if external storage is available, otherwise display an error message to the user
File sdCard = Environment.getExternalStorageDirectory();
File directory = new File (sdCard.getAbsolutePath() + "/Transit_Guide_Downloads");
directory.mkdirs();
String filename = "download_" + i + ".jpg";
File yourFile = new File(directory, filename);
while (yourFile.exists()) {
i++;
filename = "download_" + i + ".jpg";
yourFile = new File(directory, filename);
}
if (!yourFile.exists()){
if (directory.canWrite())
{
try {
FileOutputStream out = new FileOutputStream(yourFile, true);
bitmap.compress(Bitmap.CompressFormat.PNG, 90, out);
out.flush();
out.close();
Toast.makeText(SecondMap.this, "File exported to /sdcard/Transit_Guide_Downloads/screenshot" + i + ".jpg", Toast.LENGTH_SHORT).show();
i++;
} catch (IOException e) {
e.printStackTrace();
}
}
}}
else
{
Toast.makeText(SecondMap.this, "SD Card not available!", Toast.LENGTH_SHORT).show();
}
}