Save ImageView to Android Emulator Gallery

前端 未结 1 1570
囚心锁ツ
囚心锁ツ 2021-01-26 00:09

I\'d like to Save an Image to the Android Gallery, here\'s my current code:

image.setDrawingCacheEnabled(true);

image.buildDrawingCache(true);
Bitmap b = image.         


        
1条回答
  •  伪装坚强ぢ
    2021-01-26 00:37

    Since, you already have the Bitmap you can use this code to insert it into the gallery:

    Bitmap b = image.getDrawingCache();
    Images.Media.insertImage(getContentResolver(), b, title, description);
    

    title and description can be null if you don't care about setting them. If the Uri returned is non-null, then the insertion was successful.

    0 讨论(0)
提交回复
热议问题