Function written in servcie run even the Service got Destroyed
<p>I have written a funtion in service which is executing when service start .My service class is as follows</p>

<pre><code>public class SimpleService extends Service {
     public static final String TAG = "Service";
     private Timer timer = new Timer();
     @Override

     public IBinder onBind(Intent arg0) {
           return null;
     }

     @Override

     public void onCreate() {
           super.onCreate();

           Toast.makeText(this,"Service created ...", Toast.LENGTH_LONG).show();           
           Log.i(getClass().getSimpleName(), "Service started.");         
           startService() ;
     }

     @Override
     public void onDestroy() {
           super.onDestroy();

           Toast.makeText(this, "Service destroyed ...", Toast.LENGTH_LONG).show();
     }

     private void startService() {                   
         timer.scheduleAtFixedRate(new mainTask(), 0, 200000);   
     }    

     private class mainTask extends TimerTask {         
         public void run() {           
             for (int i = 0; i &lt;300; i++) { 
                 String count= String.valueOf(i);
                 Log.d(TAG, count);
             }
         } 
     }

     protected Intent  launchmain_menu() {
             Intent i = new Intent(this, SimpleService.class);
             return i;
     }

}
</code></pre>

<p>I have started my service in my main activity on create mentod as below
startService(new Intent(this, SimpleService.class));</p>

<p>Also I have written on button click to destroy the service as below
stopService(launchmain_menu());</p>

<pre><code>protected Intent  launchmain_menu() {
    Intent i = new Intent(this, SimpleService.class);
    return i;
}
</code></pre>

<p>The Problem is that even when i destroy the service the loop in the start service function</p>

<p>ie..</p>

<pre><code>for (int i = 0; i &lt;300; i++) { 
                 String count= String.valueOf(i);
                 Log.d(TAG, count);
}
</code></pre>

<p>get executed.I have check the running service in the emulitor but the service started my me is not there after i clicked the button to destroy the service.How wil the loop got executed even the service is destroyed.</p>

<p>Will any one help me after review this code pls.</p>
