title: Service is running after app is stop
body: <p>I am trying to run a service, whem i stop my app that service still run means it's continuing its task. What is the way to stop service when we stop our app? Plese help me how can i stop this service. One more thing is also there if i use intent in this class to move back to that class from where service is calling i moved back but when i press back button on emulator to go back then it display that service screen also.</p>
  
  <p><strong>I am showing the code of service class</strong></p>
  
  <pre><code>public class SetMovableBG_Inbuilt_SetImage extends Service
  {
      Timer mytimer;
      int interval = 2000;
      int interval1 = 4000;
      Drawable drawable;
      WallpaperManager wpm;
      int prev = 0;
      int numImage;
      private ArrayList&lt;Integer&gt; imgId;
  
      @Override
      public void onCreate()
      {
          super.onCreate();
          mytimer = new Timer();
          wpm = WallpaperManager.getInstance(this);
      }
  
      // here i am geting intent from the class from where i am calling this class.
      //everything  works fine but service not stops even after stop the app
      @Override
      public int onStartCommand(Intent intent, int flags, int startId)
      {
          imgId = intent.getIntegerArrayListExtra("ImgId");
          numImage = imgId.size();
          mytimer.schedule(new TimerTask()
          {
              @Override
              public void run()
              {
                  // TODO Auto-generated method stub
                  if ( prev &gt;= numImage )
                  {
                      prev = 0;
                  }
                  try
                  {
                      wpm.setResource(imgId.get(prev));
                  }
                  catch ( IOException e )
                  {
                      e.printStackTrace();
                  }
                  prev++;
              }
          }, interval, interval1);
          return super.onStartCommand(intent, flags, startId);
      }
  
      @Override
      public IBinder onBind(Intent arg0)
      {
          return null;
      }
  }
  </code></pre>