How to retrieve snapshot of map from place-picker activity?

后端 未结 5 892
时光说笑
时光说笑 2020-12-05 18:04

I\'m creating an app which picks places from the Google maps and stores the address in the database. I also want to store the snapshot of the picked place in the storage, so

5条回答
  •  旧巷少年郎
    2020-12-05 18:33

    If you want to show snapshot of the picked place in the dialog first you have to save the screen of map view into bitmap.

    Refer this code to converting your map view into bitmap

    Bitmap screen;
    View v1 = MyView.getRootView();
    v1.setDrawingCacheEnabled(true);
    screen= Bitmap.createBitmap(v1.getDrawingCache());
    v1.setDrawingCacheEnabled(false);
    

    From above code you can get Bitmap which You can further use in your Dialog box by setting this bitmap into image view. But keep in mind u have to perform all operation before generating dialog and on worker thread.

提交回复
热议问题