Is there any way to get notified before the app is being replaced by another?

半世苍凉 提交于 2019-12-11 17:01:38

问题


I know about the ACTION_MY_PACKAGE_REPLACED Intent action but what it do is - notifies the receiver AFTER the app got replaced.

But the things is - I want to know before the app is being replaced by another.

I tried with these actions

<receiver
    android:name=".receivers.InstallReceiver"
    android:enabled="true"
    android:exported="true">

       <intent-filter>
            <action android:name="android.intent.action.PACKAGE_INSTALL" />
            <action android:name="android.intent.action.PACKAGE_ADDED" />
            <action android:name="android.intent.action.PACKAGE_CHANGED" />
            <action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
       </intent-filter>
</receiver>

but doesn't help!


回答1:


I want to know before the app is being replaced by another

That is not possible, sorry.

What if I want to stop some service before the app got uninstalled?

When an app is replaced or removed, its process is terminated. The process will be terminated for many other reasons as well (e.g., old age, Force Stop in Settings). There should be no need to do something special for the replacement/uninstall scenario.



来源:https://stackoverflow.com/questions/47391915/is-there-any-way-to-get-notified-before-the-app-is-being-replaced-by-another

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!