import java.io.File;
import android.content.Intent;
import android.net.Uri;
/**
* 名称:AndroidFileUtil
*
* 描述:打开文件工具类
*/
public class AndroidFileUtil {
public static Intent openFile(String filePath) {
System.out.println("打开的文件路径 : " + filePath);
File file = new File(filePath);
if (!file.exists()) {
return null;
}
/* 取得扩展名 */
String fileName = file.getName();
String end = fileName.substring(file.getName().lastIndexOf(".") + 1,
file.getName().length()).toLowerCase();
/* 依扩展名的类型决定MimeType */
Intent intent = null;
if (end.equals("jpg") || end.equals("gif") || end.equals("png")
|| end.equals("jpeg") || end.equals("bmp")) {
intent = getImageFileIntent(filePath);
} else if (end.equals("ppt")) {
intent = getPptFileIntent(filePath);
} else
android 打开附件
最新推荐文章于 2022-05-25 13:48:37 发布
本文介绍如何在Android设备上处理和打开各类附件,包括设置Intent、处理文件类型、使用内置或第三方应用进行打开等技术要点。

最低0.47元/天 解锁文章
1214





