简体   繁体   English

取消APK下载/安装

[英]Cancel an APK download/install

I'm currently using 我目前正在使用

ret.setAction(Intent.ACTION_VIEW);
ret.setDataAndType(Uri.fromFile(apkLocation), "application/vnd.android.package-archive");

to download and install an APK from the internet within an AsyncTask's doInBackground method. 在AsyncTask的doInBackground方法中从互联网下载并安装APK。 I also have a progress dialog with a cancel button. 我还有一个带有取消按钮的进度对话框。 Upon pressing the cancel button, the APK should be deleted. 按下取消按钮后,APK将被删除。 How might I go about doing this? 我该怎么做呢?

Call delete() to delete a File . 调用delete()删除File

This may or may not stop the installation, and you have no control over that, as it is the OS, not you, that is installing the APK. 这可能会或可能不会停止安装,并且您无法控制安装,因为安装APK的是操作系统而不是您。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM