admin管理员组文章数量:1533890
2024年6月21日发(作者:)
}
}
public Intent getFileIntent(File file){
// Uri uri = ("/hpf10/");
Uri uri = le(file);
String type = getMIMEType(file);
Log.i("tag", "type="+type);
Intent intent = new Intent("");
egory("T");
gs(_ACTIVITY_NEW_TASK);
aAndType(uri, type);
return intent;
}
public void writeToSDCard(String fileName,InputStream input){
if(ernalStorageState().equals(_MOUNTED)){
File directory=ernalStorageDirectory();
File file=new File(directory,fileName);
// if(()){
// Log.i("tag", "The file has already exists.");
// return;
// }
try {
FileOutputStream fos = new FileOutputStream(file);
byte[] b = new byte[2048];
int j = 0;
while ((j = (b)) != -1) {
(b, 0, j);
}
();
();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
tackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
tackTrace();
}
}else{
Log.i("tag", "NO SDCard.");
}
}
private String getMIMEType(File f){
String type="";
String fName=e();
/* 取得扩展名 */
String end=ing(dexOf(".")+1,()).toLowerCase();
/* 依扩展名的类型决定MimeType */
if(("pdf")){
type = "application/pdf";//
}
else if(("m4a")||("mp3")||("mid")||
("xmf")||("ogg")||("wav")){
type = "audio/*";
}
else if(("3gp")||("mp4")){
type = "video/*";
}
else if(("jpg")||("gif")||("png")||
("jpeg")||("bmp")){
type = "image/*";
}
else if(("apk")){
/* L_PACKAGES */
type = "application/e-archive";
}
// else if(("pptx")||("ppt")){
// type = "application/-powerpoint";
// }else if(("docx")||("doc")){
// type = "application/-word";
// }else if(("xlsx")||("xls")){
// type = "application/-excel";
// }
版权声明:本文标题:AndroidWebView实现文件下载功能 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://m.elefans.com/xitong/1718982682a745863.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论