title: Stopping alarms after the app is killed Android
body: <p>I have a situation in my application. I am calling a service using an alarm. The alarm wakes up every 5 min and calls the service.</p>
  
  <p>But it may so happen that the user might close my app and I am allowing the functionality of the service to work even if the user is not using my app.</p>
  
  <p>To stop the service there are two ways either the user comes back to the app and presses a button which will cancel the alarm OR the second way is say after x time I want to stop the service i.e cancel the alarm from a broadcast receiver.</p>
  
  <p>Now how can I do the second way ? When I tried to get reference of the AlarmManager it is giving me error of Null Pointer. (I am accessing this alarm manager from a broadcast receiver)</p>
  
  <p>Can anyone give me suggestion on how to cancel repeating alarms from outside the activity context ?</p>
  
  <p>Thanks :)</p>