How to stop Service using Alarm Manager at a particular time in Android?
<p>In my app i want to stop the service in a particular time using Alarm Manager. But Alarm Manager cancel() method is not taking any time. So how can i stop it?</p>

<p>I wrote the code like below:</p>

<pre><code>    Intent intent = new Intent(DashboardScreen.this, com.innominds.util.ServiceClass.class);
            Log.d("Testing", "Intent created");
            PendingIntent pi = PendingIntent.getService(DashboardScreen.this, req, intent, 0);
            AlarmManager alarm_manager = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
            alarm_manager.setRepeating(AlarmManager.RTC_WAKEUP, cur_cal.getTimeInMillis(),30*1000, pi);
            Log.d("Testing", "Intent created");
            Intent intent1 = new Intent(this, com.innominds.util.ServiceClass.class);
            PendingIntent sender = PendingIntent.getService(this,
                           req, intent1, 0);
            AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
alarmManager.cancel(sender);
</code></pre>
