How to find out when an installation is completed

前端 未结 2 1192
无人共我
无人共我 2020-12-15 02:28

I am creating an application that installs apps downloaded from a server. I would like to Install these application After the file is downloaded the code for the method I a

2条回答
  •  醉梦人生
    2020-12-15 02:51

    The Android package manager sends various broadcast intents while installing (or updating / removing) applications.

    You can register broadcast receivers, so you will get notifications e.g. when a new application has been installed.

    Intents that might be interesting for you are:

    • ACTION_PACKAGE_INSTALL
    • ACTION_PACKAGE_REPLACED
    • ACTION_PACKAGE_CHANGED
    • ACTION_PACKAGE_ADDED

    Using broadcast receivers is not a big deal:

    BroadcastReceiver myReceiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {
            // do whatever you want to do
        }
    };
    
    registerReceiver(myReceiver, new IntentFilter("ACTION"));
    unregisterReceiver(myReceiver);
    

提交回复
热议问题