How to use service?
<p>I am implementing some code and I want to run it in regular time(auto refreshing after some time...)I decided to go with alarm manager,now as I know that we can use pending intent for calling some another app to do some work on behalf of our app.Here using alarm manager I start one service like..</p>

<pre><code>intent = new Intent(AutoUpdateActivity.this, AlarmService.class);
pI =  PendingIntent.getService(AutoUpdateActivity.this,0, intent, 0);
alarmManager.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,firstTime,10*1000,pI);
</code></pre>

<p>upto this everything is fine also my service runs after every 10 sec.Now when I close my app I wish to cancel alarmManager and I do it like this</p>

<pre><code>pI.cancel();
</code></pre>

<p>this is also working fine,and my service does not run again..</p>

<p>But when I go to setting and check for running services it still shows me that service running.Where I am going wrong?is there anything that I am misleading ?</p>

<p>For my easy solution I stop my service like this</p>

<pre><code>pI.cancel();
stopService(intent);
</code></pre>

<p>this cancel pI as well as stop service,but I am not sure is this correct way.
so kindly share your knowledge and let me know where i am going wrong.</p>
