相关疑难解决方法(0)

捕获GoogleMap Android API V2的屏幕截图

最后更新

功能请求已由Google完成.请在下面看到这个答案.

原始问题

使用旧版Google Maps Android API,我能够捕获谷歌地图的屏幕截图,通过社交媒体分享.我使用以下代码捕获屏幕截图并将图像保存到文件中并且效果很好:

public String captureScreen()
{
    String storageState = Environment.getExternalStorageState();
    Log.d("StorageState", "Storage state is: " + storageState);

    // image naming and path  to include sd card  appending name you choose for file
    String mPath = this.getFilesDir().getAbsolutePath();

    // create bitmap screen capture
    Bitmap bitmap;
    View v1 = this.mapView.getRootView();
    v1.setDrawingCacheEnabled(true);
    bitmap = Bitmap.createBitmap(v1.getDrawingCache());
    v1.setDrawingCacheEnabled(false);

    OutputStream fout = null;

    String filePath = System.currentTimeMillis() + ".jpeg";

    try 
    {
        fout = openFileOutput(filePath,
                MODE_WORLD_READABLE);

        // Write the string …
Run Code Online (Sandbox Code Playgroud)

android android-mapview google-maps-android-api-2

47
推荐指数
3
解决办法
4万
查看次数