一、MediaScanner 的使用
1)Intent.ACTION_MEDIA_SCANNER_SCAN_FILE:扫描指定文件
public void scanFileAsync(Context ctx, String filePath) {
Intent scanIntent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
scanIntent.setData(Uri.fromFile(new File(filePath)));
ctx.sendBroadcast(scanIntent);
}
2)“android.intent.action.MEDIA_SCANNER_SCAN_DIR”:扫描指定目录
public static final String ACTION_MEDIA_SCANNER_SCAN_DIR = "android.intent.action.MEDIA_SCANNER_SCAN_DIR";
public void scanDirAsync(Context ctx, String dir) {
Intent scanIntent = new Intent(ACTION_MEDIA_SCANNER_SCAN_DIR);
scanIntent.setData(Uri.fromFile(new File(dir)));
ctx.sendBroadcast(scanIntent);
}
二、MediaScanner 框架

三:MediaScanner 流程
