Android版本检测 自动更新
2010-10-19 20:17:10 来源:WEB开发网is.close();
} catch (Exception ex) {
Log.e(TAG, "getDataSource() error: " + ex.getMessage(), ex);
}
}
}
private void openFile(File f) {
Intent intent = new Intent();
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setAction(android.content.Intent.ACTION_VIEW);
String type = getMIMEType(f);
intent.setDataAndType(Uri.fromFile(f), type);
activity.startActivity(intent);
}
public void delFile() {
Log.i(TAG, "The TempFile(" + currentTempFilePath + ") was deleted.");
File myFile = new File(currentTempFilePath);
if (myFile.exists()) {
myFile.delete();
}
}
private String getMIMEType(File f) {
String type = "";
String fName = f.getName();
String end = fName
.substring(fName.lastIndexOf(".") + 1, fName.length())
.toLowerCase();
if (end.equals("m4a") || end.equals("mp3") || end.equals("mid")
|| end.equals("xmf") || end.equals("ogg") || end.equals("wav")) {
type = "audio";
} else if (end.equals("3gp") || end.equals("mp4")) {
type = "video";
} else if (end.equals("jpg") || end.equals("gif") || end.equals("png")
|| end.equals("jpeg") || end.equals("bmp")) {
type = "image";
} else if (end.equals("apk")) {
type = "application/vnd.android.package-archive";
} else {
type = "*";
}
if (end.equals("apk")) {
} else {
type += "/*";
}
return type;
}
}
赞助商链接