klemens
klemens

Reputation: 413

android and alarmManager

I write application which will use alarm manager. First I set up alarm manager to run some service every 20sec. Then service start some Thread. Here code of my service:

public int onStartCommand(Intent intent, int flags, int startId) {
    ExtendedLog.i(TAG, "On start command");

    Thread t = new Thread(wat);
            t.start;

    this.stopSelf();
    return START_STICKY;
}

My problme is that this running properly only for few minutes. After that alarm manager starts service but thread does not start. I really dont know where is problem. Do anyone of you know what may be wrong with it? Thanks for any help.

Upvotes: 0

Views: 389

Answers (1)

Jong
Jong

Reputation: 9125

Why are you stopping the service if you want the thread to keep running?

Looking in the Service documentation:

All cleanup (stopping threads, unregistering receivers) should be complete upon returning from onDestroy().

So since you did not stop your threads in onDestroy as requested , the system probably interrupts and stops them on its own.

What are you trying to do here? Starting a new thread & new service each 20 seconds is probably (I might even say obviously) not the best way to implement whatever you need to do... What is the code the runnable wat runs?

Upvotes: 1

Related Questions