I am developing clock Widget application in android, I have one Foreground service which is running in background, but issue is when I update the app, service has been stopped. How to keep service running after app update, I tried ACTION_MY_PACKAGE_REPLACED and placed in Broadcast Receiver but did not worked, I cant get onReceive call in that particular Receiver.
Asked
Active
Viewed 94 times
1 Answers
0
If you're testing in Android Studio, it might not be firing that broadcast at all. This question/answer gets into it - if you install through adb install
you get the broadcast, if you install with Run in AS it doesn't happen.
You basically need to build your app (either Rebuild
in the Build
menu, or with gradlew assembleDebug
on the command line) and then run adb install app\build\outputs\apk\debug\app-debug.apk
(or whatever the path is, depends where you're running it) and it should work. I'd recommend putting a log call in your receiver so you can see if it runs or not
Also make sure your receiver has android:exported=true
and android:enabled=true
in the manifest

cactustictacs
- 17,935
- 2
- 14
- 25