0

I am trying to implement something similar to facebook's like feature. I have a feed which shows posts and users can like or dislike them. I don't want users to wait until the like is recorded in the server and then show the same in their feed.

What I am trying to implement is something using android services, which records all the likes/dislikes and schedules a http call to the server to record it.

Currently this is working even if the app is in background, but not when the application is closed.

I just wanted to know what is the best way to implement such a task even when the application is closed ?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Nikhil
  • 167
  • 3
  • 16
  • With your solution you can make a foreground service to make scheduled http call(but it has few limitations please find that in documentation). Otherwise you can make an http call in Async task that is in background as soon as like button is hit, if the http call fails you can retry. Make sure to update ui as soon as the user hits the like button. – Kinjal Rathod Oct 06 '18 at 18:57
  • I am trying that way, but if the app is closed, there won't be any http request made. How to achieve this even after the app is closed ? – Nikhil Oct 07 '18 at 06:49
  • Have a look at this https://stackoverflow.com/questions/42126979/cannot-keep-android-service-alive-after-app-is-closed – Mohamed Mohaideen AH Oct 07 '18 at 09:29
  • I don't want to have a foreground service. It has to be in the background. I don't want to show the notification to the user – Nikhil Oct 07 '18 at 12:52

0 Answers0