0

Hey I m creating an app that run in background which writes its current location details to the firebase database in periodic interval of time (i.e. it will writes for every minute.). Initially i will write the location detail to location.txt file for every minute. After i did the same for for writing to the firebase instead of writing to the text file but, it will write for the first three times only then it won't write. I couldn't figure out how to write it constantly until i stop.

I m yet to upload the code but here it will shows the error (Indentation is required)...

Please help on this.. Thanks in advance..

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Sudarshan
  • 363
  • 1
  • 9
  • 1
    are you sure that your background task/service is not killed by the system? try to print a log instead of saving data to firebase database, just to see if the task is still running after 3 minutes. – Wilik Jul 05 '16 at 08:17
  • yeah i put a log message before initializing and after updating data to firebase, – Sudarshan Jul 05 '16 at 08:21
  • but it will updates exactly 3 times after that it won't @Wilik – Sudarshan Jul 05 '16 at 08:22
  • so maybe the system kills it. Is your service set to foreground? – f.khantsis Jul 05 '16 at 15:52
  • No I put a log message there that message will be printed, But it wont updates the firebase after 3 minutes – Sudarshan Jul 06 '16 at 06:47
  • what I mean was, if you delete your firebase save data code and leaves only log printing code, will the task killed after 3 minutes? is it a service or a thread? – Wilik Jul 06 '16 at 09:23
  • No @Wilik it will print the the log properly even if i delete the save data code. – Sudarshan Jul 06 '16 at 14:42
  • ok, it looks like the service is killed then, can you provide the code? are you repeating the task using AlarmManager or a runnable? you can try to use `WakefulBroadcastReceiver` instead of `BroadcastReceiver` – Wilik Jul 07 '16 at 04:28
  • Okay Here is the Link http://stackoverflow.com/questions/38227450/android-firebase-update-issue-when-the-app-is-in-background/38229289?noredirect=1#comment63890037_38229289 – Sudarshan Jul 07 '16 at 04:52

0 Answers0