Best Approach to use robospice with background task service

627 views
Skip to first unread message

Gabriel Francischini

unread,
Sep 17, 2013, 10:39:22 PM9/17/13
to robo...@googlegroups.com
Hello,

I have a task that is scheduled every 30 minutes. This task exchanges information with my webservice

I want to know what is the best approach to:

1. initialize robospice on my activity and on my service
2. dispose robospice

Any Help?

Thanks

Stéphane Nicolas

unread,
Sep 18, 2013, 1:26:10 PM9/18/13
to robo...@googlegroups.com
Hi Gabriel,

this is definitely not very hard to achieve.

1) Create a pending intent to wake up your service every 30 minutes. Your service could be an intent service.
2) in your service, in onCreate initialize a spiceManager, you will stop it after your requests are processed
3) in onCreate, after the spiceManager is created and started, execute your request.
4)  in onCreate, now wait for your listener to be called to. The easiest is to use a CountDownLatch and await for it.
5) in your listener, when either method is called, do your processing, if any and do a CountDownLatch.countDown().

Stéphane


2013/9/18 Gabriel Francischini <gpfranc...@gmail.com>

--
Vous recevez ce message, car vous êtes abonné au groupe Google Groupes RoboSpice.
Pour vous désabonner de ce groupe et ne plus recevoir d'e-mails le concernant, envoyez un e-mail à l'adresse robospice+...@googlegroups.com.
Pour plus d'options, visitez le site https://groups.google.com/groups/opt_out .



--
Stéphane NICOLAS,
OCTO Technology 
Développeur & Consultant Android / Java
..........................................................
50, Avenue des Champs-Elysées
75008 Paris
+33 (0)6.26.32.34.09
www.octo.com - mobilite.octo.com 
blog.octo.com - www.usievents.com
...........................................................
Reply all
Reply to author
Forward
0 new messages