title: Android alarm not working
body: <p>I've been struggling with this for hours. I've also checked the documentation and several topics. I found this code in two topics, both guys said the code was working perfectly, but not on my computer. The first Toast appears, but the second one never. What is wrong?</p>
  
  <pre><code>public class HelloAndroid2 extends Activity {  
  
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);   
  
      Intent intent = new Intent(this, AlarmReceiver.class);
  
      PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0,
      intent, PendingIntent.FLAG_ONE_SHOT);
  
      AlarmManager alarmManager = (AlarmManager) getSystemService(ALARM_SERVICE);
      alarmManager.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + (10 * 1000), pendingIntent);
      Toast.makeText(this, "Alarm set", Toast.LENGTH_LONG).show();
  
  }
  
   public final class AlarmReceiver extends BroadcastReceiver {
      @Override
      public void onReceive(Context context, Intent intent) {
          Toast.makeText(context, "Alarm worked.", Toast.LENGTH_LONG).show();
  
      }
   }
  </code></pre>
  
  <p>}</p>