Learn how to register a new file in the Android gallery using Beanshell code. The article explains the process of sending a broadcast intent to scan a specific file and adding it to the Android media scanner, allowing the file to be accessible within the gallery.

register new file to android gallery

code in beanshell:

1
2
3
4
5
6
import android.net.Uri;
Intent mediaScanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
Uri contentUri = Uri.parse("file:///storage/emulated/0/Movies/output0_higher.mp4");
mediaScanIntent.setData(contentUri);
ctx.sendBroadcast(mediaScanIntent);

Comments