title: Alarmmanager with pending Intent
body: <p>The code snippet below....       </p>
  
  <pre><code>public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
      ///////////Do something////////////////////////
      showtext.startScan();
      //SEt Alarm
      Intent intent = new Intent(this, TextReceiver.class);
      PendingIntent pi = PendingIntent.getBroadcast(this, 0, intent, 0);
      AlarmManager am = (AlarmManager) getSystemService(Context.ALARM_SERVICE);
      am.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()+9000, pi);}
  </code></pre>
  
  <p>And my Receiver :</p>
  
  <pre><code>TextReceiver extends BroadcastReceiver{
  
      public void onReceive(Context context, Intent intent) {
          ///Show text/////
      }
  }
  </code></pre>
  
  <p>The thing is that when I run the program after 9sn, I am getting an error that "The app stopped unexpectedly". Why I get this error? </p>
  
  <p>My goal is to show the text every 9sn. What is the correct usage of <code>AlarmManager</code> in the main activity<br>
  OR Should I set alarm in the <code>BroadcastReceiver</code> ? 
  Which one does makes sense: <code>am.setRepeating</code> or <code>am.set</code> in terms of my goal? </p>
  
  <p>**Edit: How can I change my alarm code to run in the Broadcast Receiver ? **</p>