BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 07-10-2009, 05:06 AM   #1 (permalink)
New Member
 
Join Date: Jul 2009
Model: 8300
PIN: N/A
Carrier: No Carrier
Posts: 6
Post Thanks: 0
Thanked 0 Times in 0 Posts
Question PushRegistry throught BlackBerry

Please Login to Remove!

Hi,
Can anybody tell me how to implement PushRegistry throught registerAlarm(),
so, that it will call the same MIDlet after specified time.

I have used the following sample code->

public class AlarmMidlet extends MIDlet implements CommandListener
{
DateField dateField;
Form form;
private static final Command ok= new Command ("OK",Command.OK,1);;

// Command that registers the MIDlet to launch automatically after a certain
// time period
private static final Command REGISTER_TIMER_ALARM_COMMAND = new Command("Register timer alarm", Command.ITEM, 1);

private final String MIDLET_CLASS_NAME;

public AlarmMidlet()
{
MIDLET_CLASS_NAME = this.getClass().getName();
}

public void startApp()
{
form = new Form("Welcome");
form.append("Hello AlarmMidlet");
form.addCommand(ok);
form.addCommand(REGISTER_TIMER_ALARM_COMMAND);
form.setCommandListener(this);
Display.getDisplay(this).setCurrent(form);

System.out.println("startApp");
}

public void pauseApp()
{

}
private void registerTimerAlarm(long timePeriodToAutoStart)
{
// Set the launch time to current time + the specified period
long timeToWakeUp = System.currentTimeMillis() + timePeriodToAutoStart;
long timeToWakeUp1 = System.currentTimeMillis();
System.out.println("Registering the timer alarm...");

try {
PushRegistry.registerAlarm(MIDLET_CLASS_NAME, timeToWakeUp);
System.out.println("Alarm is registered!");
System.out.println("System time:"+timeToWakeUp1);
System.out.println("Total Time :"+timeToWakeUp);
} catch (ClassNotFoundException ex) {
System.out.println(ex.getMessage());
System.out.println("Alarm registration failed.");
} catch (ConnectionNotFoundException ex) {
System.out.println(ex.getMessage());
System.out.println("Alarm registration failed.");
}
notifyDestroyed();
}

public void commandAction(Command command, Displayable displayable)
{
if (command == ok) {
// Exit the MIDlet
destroyApp(true);
} else if (command == REGISTER_TIMER_ALARM_COMMAND) {
//registering timer alarm. Alarm will start MIDlet throught
//30 seconds
registerTimerAlarm(30000);
}
}
public void destroyApp(boolean unconditional)
{

notifyDestroyed();
}
}


But it is not calling the same MIDlet after specified time.

I have used eclipse Version: 3.4.1, J2MEPolish project in which, through build.xml calling BlackBerry8300(BlackBerryJDE4.5.0)


Please help me. :(

Thanks,
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Agilent/HP 6050A 1800W Electronic Load Mainframe + 1 60501A 150W Load, Tested.
$1198.0
Agilent/HP 6050A 1800W Electronic Load Mainframe + 1 60501A 150W Load, Tested. pictureQTY.20 TELCO BOARDS IN 24FC19 14 MAINFRAME 2443-20 2440-00 2445-20 2430-2 241201
$199.99
QTY.20 TELCO BOARDS IN 24FC19 14 MAINFRAME 2443-20 2440-00 2445-20 2430-2 241201 pictureHp Agilent 8350B Sweep Oscillator Mainframe
$150.0
Hp Agilent 8350B Sweep Oscillator Mainframe pictureTektronix TM501 / AM503 Current Probe Amplifier with 1 Slot Plug-In Mainframe
$49.99
Tektronix TM501 / AM503 Current Probe Amplifier with 1 Slot Plug-In Mainframe pictureKeithley 707 6- Slot Switching Matrix Mainframe (Parts/Repair)
$59.99
Keithley 707  6- Slot Switching Matrix Mainframe (Parts/Repair)  picture






Copyright 2004-2016 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.