×

Discussion Board

Results 1 to 3 of 3
  1. #1
    Registered User
    Join Date
    May 2013
    Posts
    280

    How to set time in push registry according to users choice

    I am working on s40 and using following code.
    private void registerTimerAlarm(long timePeriodToAutoStart) {
    long day = 1000*60*60*24;
    long t = new Date().getTime() + day;
    // Set the launch time to current time + the specified period
    long timeToWakeUp = System.currentTimeMillis() + t;
    printString("Registering the timer alarm...");

    try {
    PushRegistry.registerAlarm(MIDLET_CLASS_NAME, timeToWakeUp);
    printString("Alarm is registered!");
    } catch (ClassNotFoundException ex) {
    printString(ex.getMessage());
    printString("Alarm registration failed.");
    } catch (ConnectionNotFoundException ex) {
    printString(ex.getMessage());
    printString("Alarm registration failed.");
    }
    }
    At what time above code will perform alarm? If i want user to select date and time from picker so that he can set alarm according to his own choice. How to do integrate it here?

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,692

    Re: How to set time in push registry according to users choice

    That is a long time: the current time is got twice, with System.currentTimeMillis, and also with "new Date().getTime" (as new Date() creates a timestamp for "now"), so this code snippet waits for the same amount of time which has passed from 1st of January, 1970, 00:00:00, and then an additional day.
    Try with "long timeToWakeUp = System.currentTimeMillis() + day" to wait a for a day. In fact you may rather want to try a couple minutes instead (like System.currentTimeMillis()+5*60000, 5 minutes).

    For the actual input you can experiment with LCDUI DateField or LWUIT Calendar.

  3. #3
    Registered User
    Join Date
    May 2013
    Posts
    280

    Re: How to set time in push registry according to users choice

    thanks wizard

Similar Threads

  1. Replies: 0
    Last Post: 2010-10-20, 15:06
  2. Push Registry help!!!
    By slackware15 in forum Mobile Java General
    Replies: 6
    Last Post: 2009-11-12, 19:23
  3. Push Registry
    By ovvenkatesan in forum Mobile Java Networking & Messaging & Security
    Replies: 1
    Last Post: 2008-06-01, 15:05
  4. push registry!!!!!
    By bandana in forum Mobile Java Networking & Messaging & Security
    Replies: 10
    Last Post: 2006-05-30, 11:21
  5. MIDP 2.0 Push Registry and WAP push
    By chandu_bgm in forum Mobile Java General
    Replies: 2
    Last Post: 2003-09-22, 06:54

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×