title: Service, IntentService, BroadcastReceiver or AlarmManager?
body: <p>I wish everyone is ok.</p>
  
  <p>I've been reading a lot and I'm kind of lost, I'm completly new to Android and I want to make an App.</p>
  
  <p>My first approach was to make an activity but I need my App to keep runing, so I came to think and use Service. Actually the problem is that I need the service to never stop, also when the phone restart or reboot to start the service again.</p>
  
  <p>I've figure it out how to start the service after the reboot/restart.</p>
  
  <p>What I'm doing is to start my service from my only activity this way:</p>
  
  <p>------------------- The Activity -------------------------</p>
  
  <pre><code>@Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
  
      startService(new Intent(MyActivity.this, MyService.class));
  
  }
  </code></pre>
  
  <p>------------------- The Service -------------------------</p>
  
  <pre><code>@Override
  public void onCreate() {
      Toast.makeText(this, "Auto Service Created onCreate", Toast.LENGTH_LONG).show();   
  }
  
  @Override
  public int onStartCommand(Intent intent, int flags, int startId){
      Timer timer;
  
      Toast.makeText(this, "Auto Service onStartCommand", Toast.LENGTH_LONG).show();
  
      int delay = 5000; // delay for 5 sec.
      int period = 5000; // repeat every sec.
  
      timer = new Timer();
  
      timer.scheduleAtFixedRate(new TimerTask(){
          public void run() 
          {
              System.out.println("Auto Service: Runing!");
          }   
      }, delay, period);
  
  
      return START_STICKY;
  }
  </code></pre>
  
  <p>It does work perfectly if the activity is runing or in background, but when it is send to the task list and I do manually eliminate it from there the service stops and I don't want that to happend.</p>
  
  <p><strong>QUESTIONS.-</strong></p>
  
  <p>1.- ¿How to make my service to don't get kill and keep runing?</p>
  
  <p>2.- ¿Would it be better to have a BroadcastReceiver to get an especific intend then execute my activity? (to improve battery to improve battery consumption)</p>
  
  <p>3.- If Question 2 is a better aproach, ¿Do I still need a service or could I rely on activities?</p>
  
  <p>Thank you in advance!!!</p>
  
  <p>EDIT 1.-</p>
  
  <p>Actually what I want to achieve is to launch an activity when the screen goes on (don't know yet if it's better to start it when the screen goes off or when screen goes on) do some work then finish the activity.</p>
  
  <p>Then again repeat the activity every time the screen goes on and even to keep running or start running the activity when the phone restart or reboot, much like a lockscreen app.</p>