<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <style type="text/css"> #btn{ display: block; width: 90%; height: 50px; margin: 0px auto; } </style> </head> <body> <button id="btn" type="button" class="mui-btn mui-btn-blue mui-btn-block">按钮</button> <script type="text/javascript"> document.querySelector(‘#btn‘).addEventListener(‘click‘,function () { var REQUESTCODE = 1; var main = plus.android.runtimeMainActivity(); var Intent = plus.android.importClass(‘android.content.Intent‘); var intent = new Intent(Intent.ACTION_GET_CONTENT); intent.setType("*/*");//设置类型,任意类型 //intent.setType("image/*"); //intent.setType("audio/*"); //选择音频 //intent.setType("video/*"); //选择视频 (mp4 3gp 是android支持的视频格式) intent.addCategory(Intent.CATEGORY_OPENABLE); main.startActivityForResult(intent,REQUESTCODE); main.onActivityResult = function(requestCode, resultCode, data) { if (REQUESTCODE == requestCode) { var context = main; plus.android.importClass(data); // 获得文件路径 var fileData = data.getData(); var path = plus.android.invoke(fileData, "getPath"); console.log("path:"+path); // 判断文件类型 var resolver = context.getContentResolver(); var fileType = plus.android.invoke(resolver, "getType",fileData); console.log("fileType:"+fileType); } } }) </script> </body> </html>