Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>My cycle above needs to perform those 8 steps in that exact order so IntentService would be the ideal solution.</p> </blockquote> <p>Not really. <code>IntentService</code> is designed for transactional sorts of work: do a few seconds, or maybe minutes, of work, then go away. Your need is for something that will run more indefinitely.</p> <blockquote> <p>can I create an IntentService that is completely independent from the Main Activity/UI thread so that it does not rely on the Main Activity's lifecycle or thread?</p> </blockquote> <p>An <code>IntentService</code> usually has very little to do with your process' main application thread.</p> <p>A better solution would be a regular <code>Service</code>. Use a standard Java <code>ScheduledExecutorService</code> to handle the timing of the events and triggering their work on a background thread. Start that work in <code>onStartCommand()</code> of the service, triggered by a <code>startService()</code> call from your activity. Stop that work in <code>onDestroy()</code> of your service, triggered by a <code>stopService()</code> call from your activity. In between <code>startService()</code> and <code>stopService()</code>, your service will run... for a while, at least.</p> <p>Even better, if your polling period were longer, would be to use <code>AlarmManager</code> and have it give you control at this event points in time. That way, your <code>Service</code> would not be clogging up memory all of the time. As it stands, users will be prone to task-kill your app, if they do not value your service.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload