I am writing an app that deletes an image from the Camera directory.
That works fine, and my app can re-list the files and the file is no longer present.
BUT the problem is that the device default gallery/album still shows the image thumbnail and the image when you click on it.
Once the media scanner runs again....i.e when you switch the device off then on, then the image is correctly gone from the gallery/album.
How can I force the media scanner to run and update the device gallery/album in real time?
The following code only causes a broken image thumbnail in the device gallery/album and the image cannot be displayed. But its not very elegant.
Bottom line question then:
How do I make the media scanner rescan and display the correct images in the device gallery/album in real time?
That works fine, and my app can re-list the files and the file is no longer present.
BUT the problem is that the device default gallery/album still shows the image thumbnail and the image when you click on it.
Once the media scanner runs again....i.e when you switch the device off then on, then the image is correctly gone from the gallery/album.
How can I force the media scanner to run and update the device gallery/album in real time?
The following code only causes a broken image thumbnail in the device gallery/album and the image cannot be displayed. But its not very elegant.
B4X:
Log("Delete the original file: " & filepath & filename)
File.Delete(filepath, filename)
'try and force the media scanner to refresh
Dim i As Intent
i.Initialize("android.intent.action.MEDIA_SCANNER_SCAN_FILE", "file://" & File.Combine(filepath, filename))
Dim p As Phone
p.SendBroadcastIntent(i)
Bottom line question then:
How do I make the media scanner rescan and display the correct images in the device gallery/album in real time?