Android - How to get a callback in app when app gets autoupdate in Google Playstore

925 views Asked by At

I need to clear cache and logout user everytime when app gets updated so that user will get latest data from backend. I have implement Support in-app updates but due to some playstore cache it didnt work on every users. I tried to register my broadcast receiver with following code:

<receiver android:name=".YourReceiver">
    <intent-filter>
        <action android:name="android.intent.action.PACKAGE_INSTALL" />
        <action android:name="android.intent.action.PACKAGE_ADDED" />
        <data android:scheme="package"/>
    </intent-filter>
</receiver>

IntentFilter intentFilter = new IntentFilter();
intentFilter.addAction(Intent.ACTION_PACKAGE_ADDED);
intentFilter.addAction(Intent.ACTION_PACKAGE_INSTALL);
intentFilter.addDataScheme("package");
registerReceiver(br, intentFilter);

but it didnt work and it didnt capture the app update event or removed event.

How can i capture the app update event when my app get updated automatically from playstore for the below scenario?

  1. User didn't open the app when app get update automatically
  2. User has opened the app when app get updated automatically
0

There are 0 answers