嗨,我再次使用此代码
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(Uri.fromFile(new
File(Environment.getExternalStorageDirectory() + "/download/" + "app.apk")),
"application/vnd.android.package-archive");
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
是否可以编写if语句,在进入Web下载之前检查文件是否已存在。因为我在网页打开之前得到解析错误。
我想也许这样的事情,但这是一个失败大声笑
File sdCard = Environment.getExternalStorageDirectory();
String fileStr = sdCard.getAbsolutePath() + "/Download";// + "app-release.apk";
File file = new File(fileStr, "Allcast.apk");
if (fileStr == ""){
Intent iAllcasth20 = new Intent(Intent.ACTION_VIEW,
Uri.parse(AllcastH20DL));
startActivity(iAllcasth20);
}else{
Intent promptInstall = new
Intent(Intent.ACTION_VIEW).setDataAndType(Uri.fromFile(file),
"application/vnd.android.package-archive");
startActivity(promptInstall);
}
感谢
该网站位于名为Allcasth20
的页面顶部的私人字符串中