WEB开发网
开发学院手机开发Android 开发 Android 实现版本检测\自动更新 阅读

Android 实现版本检测\自动更新

 2010-09-10 00:31:00 来源:WEB开发网   
核心提示:is.close();} catch (Exception ex) {Log.e(TAG, "getDataSource() error: " + ex.getMessage(), ex);}}}private void openFile(File f) {Intent intent = new I

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;

}

}

上一页  1 2 3 4 

Tags:Android 实现

编辑录入:coldstar [复制链接] [打 印]
赞助商链接