Now in my app, if I have persistence disk enabled... if I setvalue while offline and close app, the value sets only when I reopen it. But I want to set it when internet connection recovers. Any solution? I use firebase for android studio with java.
Asked
Active
Viewed 75 times
0
1 Answers
1
You cannot keep your app always in sync with the Firebase servers, while the app is in the background because the Android OS will eventually close it in favor of other apps.
When you enable offline persistence, it means your app writes the data locally to the device so you can continue to work with it while offline, or even if the user or operating system restarts the app.
If you want to perform some actions while the app is in the background, you should consider using a service.

Alex Mamo
- 130,605
- 17
- 163
- 193
-
What I wanted is a workmanager to sync every hour and push value to database... when app closed. However, I saw it worked even though I trigger workmanager for other child and it automatically pushes the value without sync specific child. It is like workmanager wakes the app and firebase sets value back if it is enqued – dvox Mar 02 '22 at 12:05