How can program a variable in my android application that causes appearance of a notification for each 10 minutes
<p>hi i am new in android and i should doing this projet,please can you help me?</p>

<p>this is my question:
How can program a variable in my android application that causes appearance of a notification for each 10 minutes, and after 2 hour it should stop?</p>

<p>i already search in google and found this code, i am not sure is this code can help me or not?</p>

<p>please can you tell me if it is doing the same that my question ?</p>

<pre><code>public class AlarmDemoActivity extends Activity implements View.OnClickListener { 
/** Called when the activity is first created. */
private PendingIntent mAlarmIntent;

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    findViewById(R.id.start).setOnClickListener(this);
    findViewById(R.id.stop).setOnClickListener(this);
    Intent launchIntent = new Intent(this, AlarmReceiver.class);
    mAlarmIntent = PendingIntent.getBroadcast(this, 0, launchIntent, 0);
}

@Override
public void onClick(View v) {
    AlarmManager manager = (AlarmManager)getSystemService(Context.ALARM_SERVICE);
    long interval = 5*1000; //5 seconds

    switch(v.getId()) {
    case R.id.start:
        Toast.makeText(this, "Scheduled", Toast.LENGTH_SHORT).show();
        manager.setRepeating(AlarmManager.ELAPSED_REALTIME,
                SystemClock.elapsedRealtime()+interval,
                interval,
                mAlarmIntent);
        break;
    case R.id.stop:
        Toast.makeText(this, "Canceled", Toast.LENGTH_SHORT).show();
        manager.cancel(mAlarmIntent);
        break;
    default:
        break;
    }
}

private long nextStartTime() {
    long oneDay = 24*3600*1000; //24 hours
    //Set the time to 09:00:00
    Calendar startTime = Calendar.getInstance();
    startTime.set(Calendar.HOUR_OF_DAY, 9);
    startTime.set(Calendar.MINUTE, 0);
    startTime.set(Calendar.SECOND, 0);

    Calendar now = Calendar.getInstance();
    if(now.before(startTime)) {
        return startTime.getTimeInMillis();
    } else {
        startTime.add(Calendar.DATE, 1);
        return startTime.getTimeInMillis();
    }
}
}
</code></pre>

<p>the AlarmReciver class</p>

<pre><code>public class AlarmReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
    Calendar now = Calendar.getInstance();
    DateFormat formatter = SimpleDateFormat.getTimeInstance();
    Toast.makeText(context, formatter.format(now.getTime()), Toast.LENGTH_SHORT).show();
}
}
</code></pre>

<p>This is XML:</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:id="@+id/start"
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:text="Start Alarm"
 /&gt;
 &lt;Button
android:id="@+id/stop"
android:layout_width="fill_parent" 
android:layout_height="wrap_content" 
android:text="Cancel Alarm"
 /&gt;
 &lt;/LinearLayout&gt;
</code></pre>
