wood burning stoves 2.0
The moose likes Java Micro Edition and the fly likes Activate Midlet automatically Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "Activate Midlet automatically" Watch "Activate Midlet automatically" New topic

Activate Midlet automatically

Amirthalingam Prasanna
Ranch Hand

Joined: Jan 08, 2004
Posts: 107
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.

Prasanna <br />[SCJA Beta, SCJP 1.4, SCJP 5.0 Beta]<br />[MCSD, MCPD, MCT, MVP]<br /><a href="http://www.prasanna.ws" target="_blank" rel="nofollow">My Blog</a>
necati sekkeli

Joined: Jun 21, 2004
Posts: 26
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);

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(){
Amirthalingam Prasanna
Ranch Hand

Joined: Jan 08, 2004
Posts: 107
Yes but for this my midlet should always run in the background right...can this be done?
Thx for helping me out...
Boris Ilyushonak

Joined: May 15, 2004
Posts: 10
5.4. Class Description
The API for the PushRegistry is located in package
java.lang.Object |
+ - javax.microedition.io.PushRegistry

5.5. Method Description
5.5.1. PushRegistry Method 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.

AIM: bilyush
Amirthalingam Prasanna
Ranch Hand

Joined: Jan 08, 2004
Posts: 107
Thx for the help...Cheer
I agree. Here's the link: http://aspose.com/file-tools
subject: Activate Midlet automatically
It's not a secret anymore!