Android 仅在下载时安装update.apk
如何使以下代码仅在有update.apk下载文件时激活。如果没有下载,请不要尝试安装它。在当前模式下,如果存在update.apk,则安装并激活即时错误。 非常感谢您的建议和宝贵的时间Android 仅在下载时安装update.apk,android,updates,Android,Updates,如何使以下代码仅在有update.apk下载文件时激活。如果没有下载,请不要尝试安装它。在当前模式下,如果存在update.apk,则安装并激活即时错误。 非常感谢您的建议和宝贵的时间 public class Categori extends ActionBarActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanc
public class Categori extends ActionBarActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_categori);
// Buscar AdView como recurso y cargar una solicitud.
AdView adView = (AdView)this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest);
WebView wv = (WebView) findViewById(R.id.webView);
WebSettings webSettings = wv.getSettings();
webSettings.setBuiltInZoomControls(true);
wv.loadUrl("http://android.vrt.ro/tv-update/ap5.html");
Intent promptInstall = new Intent(Intent.ACTION_VIEW)
.setDataAndType(Uri.parse("file:///sdcard/updates/update.apk"),
"application/vnd.android.package-archive");
startActivity(promptInstall);
inapoibuton();
filmebuton();
nationalebuton();
stiributon();
muzica();
documentarebunton();
sportbuton();
altlebuton();
pentrupiticibuton();
xxxbuton();
}
您可以检查apk文件是否存在,如下所示:
String sdcard = Environment.getExternalStorageDirectory().getAbsolutePath();
String path = sdcard.concat("/updates/update.apk");
if (new File(path).exists()) {
Intent promptInstall = new Intent(Intent.ACTION_VIEW)
.setDataAndType(
Uri.parse("file:///sdcard/updates/update.apk"),
"application/vnd.android.package-archive"
);
startActivity(promptInstall);
}
只需检查文件是否存在于给定路径?新建Filepath.exist我该怎么办?你能给我举个例子或者找什么吗?我是个初学者,不知道该找什么。