title: alarm app not working shows error in pendingintent
body: <p>here code for alarm </p>
  
  <p><strong>AlarmManagerExample.java</strong></p>
  
  <pre><code>package com.example.alarmmanagerexample;
  
  import java.util.Calendar;
  
  
  
  import android.os.Bundle;
  import android.os.SystemClock;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  import android.widget.DatePicker;
  import android.widget.TimePicker;
  import android.widget.Toast;
  import android.app.Activity;
  import android.app.AlarmManager;
  import android.app.PendingIntent;
  import android.content.Intent;
  
  public class AlarmManagerExample extends Activity {
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_alarm_manager_example);
  
  
          try {
               Button  btnSet = (Button) findViewById(R.id.selectButton);
                  final   DatePicker dp = (DatePicker) findViewById(R.id.scheduleTimePicker);
                  final   TimePicker tp = (TimePicker) findViewById(R.id.timePicker1);
  
                  btnSet.setOnClickListener(new OnClickListener() {
  
                      public void onClick(View v) {
                           int day = dp.getDayOfMonth();
                              int month = dp.getMonth();
                              int year = dp.getYear();
                              int currentTime =tp.getCurrentHour();
                              int currentMinute=tp.getCurrentMinute();
                          //  int hour =timePicker.getti
                              // Create a new calendar set to the date chosen
                              // we set the time to midnight (i.e. the first minute of that day)
                              Calendar c = Calendar.getInstance();
                              c.set(year, month, day);
                              c.set(currentTime, currentMinute);
                          String strDateTime = dp.getYear() + "-" + (dp.getMonth() + 1) + "-" + dp.getDayOfMonth() + " "+ tp.getCurrentHour() + ":" + tp.getCurrentMinute();
  
  
              //Create a new PendingIntent and add it to the AlarmManager
              Intent intent = new Intent(AlarmManagerExample.this, RingAlarm.class);
              PendingIntent pendingIntent = PendingIntent.getActivity(AlarmManagerExample.this,c, intent, PendingIntent.FLAG_CANCEL_CURRENT);
              AlarmManager am =
                  (AlarmManager)getSystemService(Activity.ALARM_SERVICE);
              am.setRepeating(AlarmManager.ELAPSED_REALTIME, SystemClock.elapsedRealtime(),
                      2*60*60,pendingIntent);
              Toast.makeText(AlarmManagerExample.this, "User has selected " + strDateTime, Toast.LENGTH_LONG).show();
  
              finish();// move to previous activity
                      }});
  
            } catch (Exception e) {}
      }
  }
  </code></pre>
  
  <p>above code am getting error in pendingintent line error </p>
  
  <p><strong>RingAlarm.java</strong></p>
  
  <pre><code>package com.example.alarmmanagerexample;
  
  import android.app.Activity;
  import android.content.Context;
  import android.media.MediaPlayer;
  import android.media.RingtoneManager;
  import android.net.Uri;
  import android.os.Bundle;
  import android.util.Log;
  import android.view.MotionEvent;
  import android.view.View;
  import android.view.View.OnTouchListener;
  import android.view.Window;
  import android.view.WindowManager;
  import android.widget.Button;
  
  public class RingAlarm extends Activity {
  
         MediaPlayer mp=null ;
  
          @Override
          protected void onCreate(Bundle savedInstanceState) {
  
                      super.onCreate(savedInstanceState);
                      this.requestWindowFeature(Window.FEATURE_NO_TITLE);
                      this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                              WindowManager.LayoutParams.FLAG_FULLSCREEN);
  
                      setContentView(R.layout.alarm);
                      Button stopAlarm = (Button) findViewById(R.id.stopAlarm);
  
                      mp = MediaPlayer.create(getBaseContext(),R.raw.audio);
  
  
                      stopAlarm.setOnTouchListener(new OnTouchListener() {
  
                          @Override
                          public boolean onTouch(View arg0, MotionEvent arg1) {
                              // TODO Auto-generated method stub
                              mp.stop();
                              finish();
                              return false;
                          }
                      });
  
                      playSound(this, getAlarmUri());
                  }
  
                  private void playSound(final Context context, Uri alert) {
  
  
                      Thread background = new Thread(new Runnable() {
                          public void run() {
                              try {
  
                                 mp.start();
  
                              } catch (Throwable t) {
                                  Log.i("Animation", "Thread  exception "+t);
                              }   
                          }
                   });
                   background.start();
                 }
  
                  @Override
                  protected void onDestroy() {
                      super.onDestroy();
                      mp.stop();
                  }               //Get an alarm sound. Try for an alarm. If none set, try notification,
                      //Otherwise, ringtone.
                  private Uri getAlarmUri() {
  
                      Uri alert = RingtoneManager
                              .getDefaultUri(RingtoneManager.TYPE_ALARM);
                      if (alert == null) {
                          alert = RingtoneManager
                                  .getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
                          if (alert == null) {
                              alert = RingtoneManager
                                      .getDefaultUri(RingtoneManager.TYPE_RINGTONE);
                          }
                      }
                      return alert;
                  }
  
  }
  </code></pre>
  
  <p>Bellow given data are layout pages</p>
  
  <p><strong>activity_alarm_manager_example.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:orientation="vertical" &gt;
  
      &lt;TextView
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:text="Notificatin Create" /&gt;
  
      &lt;DatePicker
          android:id="@+id/scheduleTimePicker"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content" /&gt;
  
      &lt;TimePicker
          android:id="@+id/timePicker1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content" /&gt;
  
      &lt;Button
          android:id="@+id/selectButton"
          android:layout_width="fill_parent"
          android:layout_height="wrap_content"
          android:onClick="onDateSelectedButtonClick"
          android:text="Set notification for this date" /&gt;
  
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>alarm.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
      android:orientation="vertical" android:layout_width="fill_parent"
      android:layout_height="fill_parent"&gt;
      &lt;Button android:text="Stop Alarm" android:id="@+id/stopAlarm"
          android:layout_width="wrap_content" android:layout_height="wrap_content" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p><strong>AndroidManifest.xml</strong></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.alarmmanagerexample"
      android:versionCode="1"
      android:versionName="1.0" &gt;
  
      &lt;uses-sdk
          android:minSdkVersion="8"
          android:targetSdkVersion="17" /&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@drawable/ic_launcher"
          android:label="@string/app_name"
          android:theme="@style/AppTheme" &gt;
          &lt;activity
              android:name="com.example.alarmmanagerexample.AlarmManagerExample"
              android:label="@string/app_name" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
          &lt;activity
              android:name=".RingAlarm"
              android:label="@string/app_name" /&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>how to solve this issue ??</p>