仅在下载后安装 update.apk
install update.apk only if you downloaded
我怎样才能让下面的代码只有在 update.apk 下载文件时才激活。如果未下载,请不要尝试安装它。在当前模式下,如果存在 update.apk,则会发生即时错误。
非常感谢您的建议和宝贵时间。
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);
}
我怎样才能让下面的代码只有在 update.apk 下载文件时才激活。如果未下载,请不要尝试安装它。在当前模式下,如果存在 update.apk,则会发生即时错误。 非常感谢您的建议和宝贵时间。
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);
}