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 框架

Android  MediaScanner

三:MediaScanner 流程

Android  MediaScanner

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-29
  • 2021-07-05
  • 2021-08-14
  • 2022-12-23
猜你喜欢
  • 2021-10-29
  • 2021-11-06
  • 2022-01-14
  • 2021-09-05
  • 2021-09-17
  • 2022-12-23
相关资源
相似解决方案