|

楼主 |
发表于 2019-3-28 16:17:35
|
显示全部楼层
本帖最后由 chengdu_lifei 于 2019-3-28 16:18 编辑
问题已解决,分享一下,添加webintent插件,修改一下webintent插件下面的WebIntent类:
void sendBroadcast(String action, Map<String, String> extras) {
Intent intent = new Intent();
intent.setAction(action);
for (String key : extras.keySet()) {
String value = extras.get(key);
intent.putExtra(key, value);
}
if(extras.get("fileSrc")!=null){//扫描多媒体用
intent.setData(Uri.parse(extras.get("fileSrc")));
}
((CordovaActivity)this.cordova.getActivity()).sendBroadcast(intent);
}
使用代码:
window.plugins.webintent.sendBroadcast({
action: 'android.intent.action.MEDIA_SCANNER_SCAN_FILE',
extras: {
"fileSrc":"file:///storage/emulated/0/xxx/alipay.png"
}
}, function() {
}, function() {
});
如果不行,在安卓配置文件中添加权限
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
<uses-permission android:name="android.intent.action.MEDIA_SCANNER_SCAN_DIR" />
|
|