title: Delayed actions and BroadcastReceiver
body: <p>I have a case in which I have to start some non-UI action <strong>N seconds after</strong> power has been connected to the device. That action could be also started by user via UI.</p>
  
  <p>I have a BroadcastReceiver defined in <strong>AndroidManifest.xml</strong> which listens for <strong>ACTION_POWER_CONNECTED</strong>.</p>
  
  <p>I have a service that does required action on <strong>onStartCommand</strong>. My question is - what is the right way to start that service in case of when action is triggered by broadcast?</p>
  
  <p>I have two options in mind:</p>
  
  <ol>
  <li><p>One-shot timer task. However I think it might be wrong because of according to docs, I could't start any async tasks from BroadcastReceiver. </p></li>
  <li><p>Redesign service:</p>
  
  <ul>
  <li>start action at <strong>onStartCommand</strong>, if action was triggered by user</li>
  <li>start timer task and do action at timer shot - same logic as in 1. but inside service - if action was triggered by broadcast.</li>
  </ul></li>
  </ol>
  
  <p>I am inclined to 2. It will make code a bit more complex, but it seems it is only right way.</p>
  
  <p>-Lev</p>