title: Libgdx + android.app.Service, how to?
body: <p>So i want to do certain things always run in background. I've read that to do that i need to use android.app.Service, so i could not find anything that explain how to do this with libgdx so i did this.</p>
  
  <p>on the AndroidLauncher I added this line</p>
  
  <pre><code>startService(new Intent(getBaseContext(),MyServices.class));
  </code></pre>
  
  <p>MyServices.class extends Service and on onStartCommand() i added a new thread that has a infinite loop, like this:</p>
  
  <pre><code>@Override
  public int onStartCommand(Intent intent, int flags, int startId) {      
      new Thread(){
          private long startTime;
          public void run() {
              while(true){
                  if(System.currentTimeMillis() - startTime &gt;= 1000){
                      startTime = System.currentTimeMillis();
                      System.out.println("running");
                  }
              }
          };
      }.start();
      return START_STICKY;
  }
  </code></pre>
  
  <p>The app keeps printing "running" every second even when the app is not running, but I feel like this is not the correct way to do this, can someone please enlighten me? Thanks</p>