Multiple Alarm Problem

General topics about the Android-Platform itself.
Coding issues please to the subforum right below.

Multiple Alarm Problem

Postby satish21131 » Mon Feb 04, 2008 11:33 am

Hi All,

I am able to execute single alarm app successfull, but if i make using for multiple alarms then i am facing the problem. The problem is if we set for the different alarm timings but we are able to get alarm for only once
(For example if button1 set for 15secs,button2 set for 30secs and button3 sets for 45secs. If button2 get selected after selecting button1 and button3 then alarm notification shows only for 30secs how to show the alarm for 3 timings).

Thanks,
Satish
satish21131
Freshman
Freshman
 
Posts: 4
Joined: Mon Feb 04, 2008 6:02 am

Top

Postby plusminus » Tue Feb 05, 2008 10:06 am

Hello satish,

The Alarm Manager is intended for cases where you want to have your application code run at a specific time, even if your application is not currently running. For normal timing operations (ticks, timeouts, etc) it is easier and much more efficient to use Handler.

Have a look at this post, where I described how to do time-delayed invocation of "things":
:arrow: http://www.anddev.org/viewtopic.php?p=3188#3188

It basically wirks like this:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.      public void onCreate(Bundle icicle) {
  2.  
  3.           super.onCreate(icicle);
  4.  
  5.           setContentView(R.layout.splashscreen);
  6.  
  7.          
  8.  
  9.           /* New Handler to start the Menu-Activity
  10.  
  11.            * and close this Splash-Screen after some seconds.*/
  12.  
  13.           new Handler().postDelayed(new Runnable(){
  14.  
  15.                @Override
  16.  
  17.                public void run() {
  18.  
  19.                     /* Create an Intent that will start the Menu-Activity. */
  20.  
  21.                     Intent mainIntent = new Intent(Splash.this,Menu.class);
  22.  
  23.                     Splash.this.startActivity(mainIntent);
  24.  
  25.                     Splash.this.finish();
  26.  
  27.                }
  28.  
  29.           }, SPLASH_DISPLAY_LENGHT);
  30.  
  31.      }
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Multiple Alarm Problem

Postby satish21131 » Tue Feb 05, 2008 12:18 pm

Hi plusminus,

Thanks for your reply.In my application several tv programs exist.I want to set alarm for each program.hence the user can be indicated when the program get started.even he is not using the application also user should be indicated about the program start time.that is why i need to set multiple alarm.So is it possible to set alarm for each program.

Thanks,
Satish
satish21131
Freshman
Freshman
 
Posts: 4
Joined: Mon Feb 04, 2008 6:02 am

Postby plusminus » Tue Feb 05, 2008 12:26 pm

Hello satish,

Note: The Alarm Manager is intended for cases where you want to have your application code run at a specific time, even if your application is not currently running.

So in my view the Alarm Manager shall be used to wake your program up at a specific time.
You could do the following if the user selected more than one program to be notified of:
  1. Get the earliest one and set the Alarm Manager to wake program up on that time.
  2. Then internally work with Handler as long as Program is running
  3. If program is sent to background (would probably be onFreeze() or sth.), repeat step 1.

Thats how I would do it.

:idea: The Handler-Class also provides a method postAtTime (probably only works if application is running!):
postAtTime(Runnable r, long uptimeMillis)
Causes the Runnable r to be added to the message queue, to be run at a specific time given by uptimeMillis.


Hope I could help you.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby kali » Sat May 02, 2009 9:09 am

hai plusminus
Is it possible to call alarm clock default application from any other application by just clicking button
please tell me if possible then send me code or link.
kali
Experienced Developer
Experienced Developer
 
Posts: 62
Joined: Tue Jan 27, 2009 1:31 pm

Top

Return to General

Who is online

Users browsing this forum: No registered users and 6 guests