Android:截屏programiticalluy不显示谷歌地图

时间:2015-09-09 17:04:49

标签: android google-maps android-fragments

我正在开发一个Android应用程序,它截取包含谷歌地图的片段的截图。当用户点击分享按钮时,它会获取片段视图的屏幕截图,并允许用户通过电子邮件分享。以下是我的片段视图。 Actual fragment view showing route on the map

当我尝试截取地图的截图时,我得到以下结果 after taking screenshot

以下是我拍摄屏幕截图的代码:

public static File takeScreenShot(View view) {
    String path = Environment.getExternalStorageDirectory().toString() + "/" + System.currentTimeMillis()+ ".jpg";

    view.setDrawingCacheEnabled(true);
    Bitmap bitmap = Bitmap.createBitmap(view.getDrawingCache());
    view.setDrawingCacheEnabled(false);

    OutputStream out = null;
    File imageFile = new File(path);

    try {
        out = new FileOutputStream(imageFile);
        // choose JPEG format
        bitmap.compress(Bitmap.CompressFormat.JPEG, 90, out);
        out.flush();
    } catch (FileNotFoundException e) {
        // manage exception
    } catch (IOException e) {
        // manage exception
    } finally {

        try {
            if (out != null) {
                out.close();
            }

        } catch (Exception exc) {
        }

    }

    return imageFile;
}

以下是共享地图视图的代码

    Intent intentShare = new Intent(Intent.ACTION_SEND);
    intentShare.setType("image/*");
    intentShare.putExtra(Intent.EXTRA_STREAM, Uri.parse(ScreenShotTaker.takeScreenShot(view).toURI().toString()));
    startActivity(intentShare);

0 个答案:

没有答案