Yeah that makes sense, thanks Diogo,
Mark
On Dec 28, 8:20 pm, "Diogo Ferreira" <di....@underdev.org> wrote:
I believe the main idea is that the main service thread is free to answer
requests and not blocked by data fetching/whatever. As you can imagine a
blocked service would ruin not only the service but applications that use
it.
On 12/29/07, Mark Wyszomierski <mar...@gmail.com> wrote:
In my remote service, I want to do some action every N seconds.
For now, I just implemented Runnable:
public class MyServiceTest extends Service implements Runnable
create a thread in onCreate():
protected void onCreate()
{
Thread thread = new Thread(null, this, "Test");
thread.start();
}
and then have that thread sleep for N seconds, then do the required
tasks:
public void run()
{
while (true) { // until we are shut down...
try {
Thread.sleep(5000);
} catch (Exception ex) {}
Log.i("MyServiceTest", "Checking in from secondary
thread..");
}
}
Is this the way google recommends us doing this sort of thing (this is
pretty much taken from the NotifyingService example in the SDK). Can
we achieve the same thing in the Service's main thread. instead of
having this secondary thread doing it?
Thanks,
Mark- Hide quoted text -