记录
之前用的是下面的代码
Intent intent = new Intent(Intent.ACTION_MEDIA_SCANNER_SCAN_FILE);
intent.setData(Uri.fromFile(myCaptureFile ));
sendBroadcast(intent);//发送一个广播
发现在某些手机上不好使,然后通过查找资料替换为下面的代码
MediaScannerConnection.scanFile(context, new String[]{file.getAbsolutePath()}, null, null);
先记录下
本文记录了在某些手机上使用Intent.ACTION_MEDIA_SCANNER_SCAN_FILE发送广播进行文件扫描时遇到的问题,并分享了一种有效的替代方案:使用MediaScannerConnection.scanFile方法来确保文件能够被系统正确扫描。
2262

被折叠的 条评论
为什么被折叠?



