Notice that the newly added photos(copied over using "adb push" into Pictures folder) are not included in the MediaStore Content Provider. Is there a way to trigger the rescan programmatically?
Already tried:
sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,Uri.parse(Environment.getExternalStorageDirectory().getPath())));
and
sendBroadcast(new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE,Uri.parse(Environment.getExternalStorageDirectory().getPath() + "/Pictures")));
which seem not work.
The broadcast Intent.ACTION_MEDIA_MOUNTED
cannot be used after Android 4.4.
(1) Other than using MediaScannerWrapper to scan files myself, is there other way to programmatically trigger the rescan?
(2) Under what circumstances will the rescan happen in Android?
Already tried
You are passing a directory, not a file.
is there other way to programatically trigger the rescan?
Use MediaScannerConnection
and its scanFile()
method. This too requires a file AFAIK.