下载 - Android 如何实现app安装完成后删除apk安装文件?
高洛峰
高洛峰 2017-04-17 17:42:46
0
5
932

注意我是自己的app安装更新完成以后,不是监听第三方的

高洛峰
高洛峰

拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...

reply all(5)
小葫芦

That’s it. Generally speaking, the process of installing a third-party app is that the user or other application triggers the original apk file on the sdcard to install. The system installation process will copy the apk to the /data/app directory for installation, and This path can be queried by all applications. Part of the so-called system restart is to reinstall all applications in the /data/app directory. So if the poster wants to delete it, it is basically equivalent to uninstalling his own app.

Of course, you can monitor the installation of the app and delete the original apk file on the sdcard.

Peter_Zhu

You need to meet two points:
1. Your app needs to be started after installing the update
2. You need to know the path of the apk

洪涛

If it is an automatic update, you can definitely control the file download location.
Now that you can control the file download location yourself, it is easy to delete a file at a specified location.

I don’t know where the difficulty lies. Maybe I missed something?

Peter_Zhu

New versions have a first-time startup tag (used for boot pages and the like). Use it to control whether this version is installed for the first time. Then delete it according to the method above.

迷茫

Listen to system application installation or update broadcasts
<action android:name="android.intent.action.PACKAGE_ADDED" />
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<action android:name="android.intent.action.PACKAGE_REMOVED" />
<data android:scheme="package" />
The last line must be added, and then from the obtained Intent Extract the package information, intent.getDataString(), see if it is yours, and then delete it

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template