Android PackageInstaller, re-open the app after it updates itself

前端 未结 1 1561
一个人的身影
一个人的身影 2020-12-17 16:17

I\'m developing an app that runs as Device Owner, and I want to build an automatic updater inside it.

To do it I use the PackageInstaller, as I have the privileges t

相关标签:
1条回答
  • 2020-12-17 17:15

    Starting from about Android 5 (I don't know the exact API level), Android will send a broadcast Intent with ACTION="android.intent.action.MY_PACKAGE_REPLACED" after your app is updated. Just add

            <intent-filter>
                <action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
            </intent-filter>
    

    to your <receiver> declaration and you should be able to listen for this and restart your app in onReceive().

    0 讨论(0)
提交回复
热议问题