• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Activate Midlet automatically

 
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,
I am developing an application using Midlets...I want my midlet to be activated automatically at a particular time of the day.Can anyone tell me how to do this please.
 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sure you can do this... The TimerTask class can be used for that. This can be the procedure:
1-first write a midlet class and create a timer and date instance
2-second, write a class by extending TimerTask and write what to do periodically.
3- declare the period or schedule for the extenden TimerTask. It will work in its period until the main application comes end. (you can handle it)

You can set the date and time to today and declare the period of that. So it will be a schedule task

-------------------------------------------------------------------------
For example:
public class yourMidlet extends javax.microedition.midlet.MIDlet {
Timer timer = new Timer();
Calendar date = Calendar.getInstance();
date.set(Calendar.HOUR, 0);
date.set(Calendar.MINUTE, 0);
date.set(Calendar.SECOND, 0);
date.set(Calendar.MILLISECOND, 0);

timer.schedule(
deneme,
date.getTime(),
1000 * 30 * 1 * 1 * 1//in every thirty seconds
);

notifyDestroyed();//to destroy the midlet (will be after the app)

}


================================================================
public class connectGPRS extends TimerTask {
public void run(){
//WHAT YOU WILL DO WIL BE WRITTEN HERE
}
}
 
Amirthalingam Prasanna
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes but for this my midlet should always run in the background right...can this be done?
Thx for helping me out...
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
5.4. Class Description
The API for the PushRegistry is located in package
javax.microedition.io.
java.lang.Object |
+ - javax.microedition.io.PushRegistry

5.5. Method Description
5.5.1. PushRegistry Method
5.5.1.1. registerAlarm static long registerAlarm (String midlet, long time) throws ClassNotFoundException, ConnectionNotFoundException

You can delete a previously registered alarm by setting the time parameter to zero. The registered time must be local time. The time must be a minimum of two minutes in the future from the current time.
 
Amirthalingam Prasanna
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thx for the help...Cheer
 
Where all the women are strong, all the men are good looking and all the tiny ads are above average:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic