my dog learned polymorphism*
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "Activate Midlet automatically" Watch "Activate Midlet automatically" New topic
Author

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
Greenhorn

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);

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

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
Greenhorn

Joined: May 15, 2004
Posts: 10
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.


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
 
Similar Threads
Incomming call and Midlet
Need some info about the Register Alarm
PushRegistry features on MIDP 2.0
Midlet Suite - MIDP 1.0
How to download a midlet from a midlet?