Hi,Try using

am.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis()+(delay * 1000)
, sender);

This will set the alarms according to the delay that you specify.



On Sun, Apr 26, 2009 at 3:42 PM, guruk <ilovesi...@gmail.com> wrote:

>
> Hi, i like to create multiple alarms, but i does not work. how to set
> and how to request in my receiver what alarm intent came activated
>
> in my alarm.java i call this function like: setalarm(5); setalarm(10)
> (it works but only remember the last)
>
>
>  public void setalarm(int delay)
>    {
>         Intent intent = new Intent(alarm.this, alarmreceiver.class);
>         PendingIntent sender = PendingIntent.getBroadcast(alarm.this,
> 0, intent, 0);
>         intent.setData((Uri.parse("custom://"+delay)));  << i heared
> about this would make individual alarms.. but does not work
>
>         Calendar calendar = Calendar.getInstance();
>         calendar.setTimeInMillis(System.currentTimeMillis());
>         calendar.add(Calendar.SECOND, delay);
>
>         intent.putExtra("avr", ""+delay);   //i tried to set my data
> here to read later, but also does not work
>
>
>         AlarmManager am = (AlarmManager)getSystemService
> (ALARM_SERVICE);
>         am.set(AlarmManager.RTC_WAKEUP, calendar.getTimeInMillis(),
> sender);
>
>         //Toast.makeText(this, "Alarm set", Toast.LENGTH_LONG).show
> ();
>
>    }
>
> ---- my alarmreceiver.java
>
> public class alarmreceiver extends BroadcastReceiver
> {
>        NotificationManager mNM;
>        @Override
>  public void onReceive(Context context, Intent intent)
>  {
>                Uri ursistr = intent.getData();
>                String intentstr = intent.getStringExtra("avr");  //does not
> get the
> saved intentextra?!
>
>        Toast.makeText(context, "GOT IT :"+intentstr+" "+ursistr,
> Toast.LENGTH_SHORT).show();
>
>  }
>
> greets
> chris
>
>
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers-unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to