Skip to content

Instantly share code, notes, and snippets.

@JakeSteam
Last active December 6, 2019 01:31
Show Gist options
  • Save JakeSteam/4561f0f46a7b08be50785a72559f8fef to your computer and use it in GitHub Desktop.
Save JakeSteam/4561f0f46a7b08be50785a72559f8fef to your computer and use it in GitHub Desktop.
<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>
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