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

Sylvania ECG 128 NPN Transistor
$6.0
Sylvania ECG 128 NPN Transistor picture TRIAC 6 AMPS AT 50 VOLTS, 276-1003 Radio Shack NEW
$6.0
 TRIAC 6 AMPS AT 50 VOLTS, 276-1003 Radio Shack NEW picture3.7V of inductor-capacitor ESR meter MG328 multifunction transistor tester TB
$12.39
3.7V of inductor-capacitor ESR meter MG328 multifunction transistor tester   TB pictureNEW TOSHIBA S7 VFS7-4022UPL (2) TRANSISTOR INVERTER VFD 3 PHASE 5.0A 4KVA 460V
$50.0
NEW TOSHIBA S7 VFS7-4022UPL (2) TRANSISTOR INVERTER VFD 3 PHASE 5.0A 4KVA 460V picture psmn7r0-30yl,115 mosfet, n ch, 30v, 76a, 4-sot-669 (1 piece)
$15.5
 psmn7r0-30yl,115 mosfet, n ch, 30v, 76a, 4-sot-669 (1 piece) picture






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