Android - Why my saved image is not appearing in the default gallery of my phone?

前端 未结 5 945
时光说笑
时光说笑 2021-01-14 01:44

I am trying to save an image from my application to the default gallery of my phone. The code below works perfectly if I have a SD card on the phone. The image saved appears

5条回答
  •  不思量自难忘°
    2021-01-14 02:18

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
    
                    sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,
                            Uri.parse("file://"
                                    + Environment.getExternalStorageDirectory())));
                } else {
                    sendBroadcast(new Intent(Intent.ACTION_MEDIA_MOUNTED,
                            Uri.parse("file://"
                                    + Environment.getExternalStorageDirectory())));
                }
    

提交回复
热议问题