search

Home  >  Q&A  >  body text

下载 - Android 如何实现app安装完成后删除apk安装文件?

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

高洛峰高洛峰2886 days ago936

reply all(5)I'll reply

  • 高洛峰

    高洛峰2017-04-17 17:44:46

    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.

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-17 17:44:46

    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

    reply
    0
  • PHP中文网

    PHP中文网2017-04-17 17:44:46

    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?

    reply
    0
  • 天蓬老师

    天蓬老师2017-04-17 17:44:46

    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.

    reply
    0
  • 迷茫

    迷茫2017-04-17 17:44:46

    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

    reply
    0
  • Cancelreply