-
-
Save albodelu/32db6dce3e16386805eae300189567da to your computer and use it in GitHub Desktop.
App upgrade listener proof of concept: https://blog.jakelee.co.uk/how-to-create-and-test-an-app-update-listener/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="uk.co.jakelee.updatelistener"> | |
<application | |
android:allowBackup="true" | |
android:icon="@mipmap/ic_launcher" | |
android:label="@string/app_name" | |
android:roundIcon="@mipmap/ic_launcher_round" | |
android:supportsRtl="true" | |
android:theme="@style/AppTheme"> | |
<activity android:name=".MainActivity"> | |
<intent-filter> | |
<action android:name="android.intent.action.MAIN"/> | |
<category android:name="android.intent.category.LAUNCHER"/> | |
</intent-filter> | |
</activity> | |
<receiver android:name=".AppUpgradeReceiver"> | |
<intent-filter> | |
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" /> | |
</intent-filter> | |
</receiver> | |
</application> | |
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AppUpgradeReceiver : BroadcastReceiver() { | |
@SuppressLint("UnsafeProtectedBroadcastReceiver") | |
override fun onReceive(context: Context?, intent: Intent?) { | |
if (context == null) { | |
return | |
} | |
Toast.makeText(context, "Updated to version #${BuildConfig.VERSION_CODE}!", Toast.LENGTH_LONG).show() | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment