java-melwuitalarmnokia-s40

Nokia S40 PushRegistry


I'm building a dummy app to see how it's working the pushregistry alarm, but I don't get it working. When I run it, I don't see anything...

Any idea?

here is my code (LWUIT with SDK 2.0, S40)

package mobileapplication2;

import com.sun.lwuit.Display;
import com.sun.lwuit.Form;
import com.sun.lwuit.Label;
import javax.microedition.io.ConnectionNotFoundException;
import javax.microedition.io.PushRegistry;
import javax.microedition.midlet.*;

/**
 * @author S40
 */
public class Midlet extends MIDlet implements Runnable {

    public Midlet() {
        Display.init(this);
    }

    public void startApp() {
        Display.getInstance().callSerially(this);
    }

    public void pauseApp() {
    }

    public void destroyApp(boolean unconditional) {
    }

    public void run() {
        try {
            PushRegistry.registerAlarm(getClass().getName(), System.currentTimeMillis() + 100000);
            Form f = new Form("Example");
            f.addComponent(new Label("HOLA"));
            f.show();
        } catch (ClassNotFoundException ex) {
            System.out.println("NOT FOUND");
            ex.printStackTrace();
        } catch (ConnectionNotFoundException ex) {
            System.out.println("CONNECTION");
            ex.printStackTrace();
        }
    }
}

Solution

  • I get it finally working

    This is my final code if you want to take a look

                java.util.Calendar cal = Calendar.getInstance();
                cal.setTimeZone(TimeZone.getTimeZone("GMT"));
                cal.set(Calendar.MONTH, Calendar.NOVEMBER);
                cal.set(Calendar.DAY_OF_MONTH, 18);
                cal.set(Calendar.AM_PM, Calendar.PM);
                cal.set(Calendar.HOUR_OF_DAY, 15);
                cal.set(Calendar.MINUTE, 27);
                cal.set(Calendar.SECOND, 0);
                System.out.println("CALE " + cal.getTime().toString());
                Date d = new Date();
                long l = PushRegistry.registerAlarm(getClass().getName(), cal.getTime().getTime());