1

I have a server running on some where and an Android application for end user. From Android application user can delete message, and this delete message will trigger sending a delete request to server through REST and server will delete it.

Does anyone know how the gmail's delete message works? Even if I quit from app or move away from app the send, delete or other operations completes eventually. Are they using AsyncTask or Thread or Service. I guess its not AsyncTask since user can move away from current view or can move away from whole application.

any suggestion is appreciated.

Jahid Shohel
  • 1,395
  • 4
  • 18
  • 34
  • I don't know how gmail app works, but what you could do, is enqueue your actions in a sqlite DB, and have an AlaramManager with a IntentService run every so often to execute the actions stored in the DB. – mbmc Jan 13 '14 at 19:48
  • I am not sure if using DB is a good idea or not. If I do, then I will be needing transaction support for DB operations. As you know that there can be multiple operations executing same time. – Jahid Shohel Jan 13 '14 at 21:38

2 Answers2

0

You may want to look at IntentService. http://developer.android.com/training/run-background-service/create-service.html

"The IntentService class provides a straightforward structure for running an operation on a single background thread. This allows it to handle long-running operations without affecting your user interface's responsiveness. Also, an IntentService isn't affected by most user interface lifecycle events, so it continues to run in circumstances that would shut down an AsyncTask"

pree
  • 2,297
  • 6
  • 37
  • 55
0

I'm not sure how Gmail's REST API works, but for REST calls, AsyncTask is definitely not the way to go. Why reinvent the wheel? Take a look at Volley or RetroFit. They are both REST libraries that take into account a lot of pitfalls one encounters in implementing REST calls in Android.

soundsofpolaris
  • 596
  • 3
  • 12