title: Stop alarmManager from other activity
body: <p>I am trying to stop the alarmManager in the MainActivity from the <code>onBackPressed()</code> method in the Map activity. I have tried the code below but the alarmManager is not being stoped and still firing. How can I fix it?</p>
  
  <p><strong>Code in the MainActivity:</strong></p>
  
  <pre><code>Intent intent = new Intent(MainActivity.this, GetLLRD.class);
  intent.putExtra("json_data", json);
  PendingIntent pendingIntent = PendingIntent.getService(
          getApplicationContext(), 123, intent, PendingIntent.FLAG_UPDATE_CURRENT);
  AlarmManager alarm = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
  Calendar cal = Calendar.getInstance();
  alarm.setRepeating(AlarmManager.RTC_WAKEUP,
  System.currentTimeMillis(), 20 * 1000, pendingIntent);
  startService(intent);
  </code></pre>
  
  <p><strong>Code in the Map Activity:</strong></p>
  
  <pre><code>@Override
  public void onBackPressed() {       
      Intent intent = new Intent(Map.this, MainActivity.class);
      PendingIntent pendingIntent = PendingIntent.getService(
              getApplicationContext(), 123, intent, PendingIntent.FLAG_UPDATE_CURRENT);
  
      AlarmManager alarm = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
      alarm.cancel(pendingIntent);
  }
  </code></pre>