亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

捕獲GoogleMap Android API V2的屏幕截圖

捕獲GoogleMap Android API V2的屏幕截圖

catspeake 2019-08-12 17:20:12
捕獲GoogleMap Android API V2的屏幕截圖使用舊版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 to the file         bitmap.compress(Bitmap.CompressFormat.JPEG, 90, fout);         fout.flush();         fout.close();     }      catch (FileNotFoundException e)      {         // TODO Auto-generated catch block         Log.d("ImageCapture", "FileNotFoundException");         Log.d("ImageCapture", e.getMessage());         filePath = "";     }      catch (IOException e)      {         // TODO Auto-generated catch block         Log.d("ImageCapture", "IOException");         Log.d("ImageCapture", e.getMessage());         filePath = "";     }     return filePath;}但是,api的V2使用的新GoogleMap對象沒有像MapView那樣的“getRootView()”方法。我試著這樣做:    SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()             .findFragmentById(R.id.basicMap);     View v1 = mapFragment.getView();但我得到的截圖沒有任何地圖內容,看起來像這樣: 有沒有人想出如何截取新的谷歌地圖Android API V2的截圖?
查看完整描述

3 回答

?
繁華開滿天機

TA貢獻1816條經驗 獲得超4個贊

由于使用OpenGL顯示新的Android API v2 Maps,因此無法創建屏幕截圖。


查看完整回答
反對 回復 2019-08-12
  • 3 回答
  • 0 關注
  • 719 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號