×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 17
  1. #1
    Regular Contributor
    Join Date
    Mar 2010
    Posts
    136

    EventList program ( how to make an alarm? )

    I am reading about PIM and try to write a program that will make alarm after some time preriod from the current time.
    But the program do not produce any sound and any display.
    What is the problem?
    Code:
    if(c==cmdEventcreate)
    		{
    			PIM pim;
    			EventList eventlist=null;
    			Event event;
    			pim=PIM.getInstance();
    			try {
    				eventlist=(EventList) pim.openPIMList(PIM.EVENT_LIST, PIM.WRITE_ONLY);
    			} catch (PIMException e) {
    				// TODO Auto-generated catch block
    				e.printStackTrace();
    			}
    			
    			event=eventlist.createEvent();
    			if(eventlist.isSupportedField(Event.START))
    			{
    				Date date=new Date();
    				long l=date.getTime()+ 6;
    				event.addDate(Event.START, Event.ATTR_NONE, l);
    				
    			}
    			
    			if(eventlist.isSupportedField(Event.ALARM))
    				event.addInt(Event.ALARM, Event.ATTR_NONE, 600);
    			event.addString(Event.SUMMARY,Event.ATTR_NONE, "Please  ");
    			try {
    				event.commit();
    				System.out.println(event.countValues(Event.ALARM));
    				System.out.println(event.countValues(Event.START));
    			} catch (PIMException e) {
    				// TODO Auyo-generated catch block
    				e.printStackTrace();
    			}
    			
    			
    		}//if(c==cmdEvnetcreate)

  2. #2
    Registered User
    Join Date
    Oct 2009
    Location
    Noida
    Posts
    941

    Re: EventList program ( how to make an alarm? )

    Check this line:
    long l=date.getTime()+ 6;

    Its adding 6 milliseconds to the current time, try with adding 5 min = 5*60*1000 milliseconds and then test.

    Check the device Native Calendar app; if event with Name Please is added to the event list ?
    Thanks,
    Ekta

  3. #3
    Regular Contributor
    Join Date
    Mar 2010
    Posts
    136

    Re: EventList program ( how to make an alarm? )

    I have changed that. But it still does not work.
    I have also changed the duration of the alarm time.

  4. #4
    Registered User
    Join Date
    Oct 2009
    Location
    Noida
    Posts
    941

    Re: EventList program ( how to make an alarm? )

    Quote Originally Posted by komomo View Post
    I have changed that. But it still does not work.
    I have also changed the duration of the alarm time.
    Check the device Native Calendar app; if event with Name Please is added to the event list ?

    On some device's the entry to native Calendar by J2me is visible only after device reboot.
    Thanks,
    Ekta

  5. #5
    Regular Contributor
    Join Date
    Mar 2010
    Posts
    136

    Re: EventList program ( how to make an alarm? )

    I am sorry to ask you like that.
    But how to check the device Native Calendar app?

  6. #6
    Registered User
    Join Date
    Oct 2009
    Location
    Noida
    Posts
    941

    Re: EventList program ( how to make an alarm? )

    which device you are testing this on ?

    Generally every device has a Calendar application, that you can access from device main menu.
    Thanks,
    Ekta

  7. #7
    Regular Contributor
    Join Date
    Mar 2010
    Posts
    136

    Re: EventList program ( how to make an alarm? )

    Now i am using ClamshellCldcPhone1. Previously I use DefaultCldcPhone1.

  8. #8
    Registered User
    Join Date
    Oct 2009
    Location
    Noida
    Posts
    941

    Re: EventList program ( how to make an alarm? )

    Try this on some real mobile handset which supports JSR-75 PIM API's or try to test on Nokia RDA.

    http://www.forum.nokia.com/Devices/R...device_access/
    Thanks,
    Ekta

  9. #9
    Regular Contributor
    Join Date
    Mar 2010
    Posts
    136

    Re: EventList program ( how to make an alarm? )

    esktasrv!
    Please don't be angry.
    I can't use Remote device acess becasue its need admin's permission to download tht.
    Is there any other way? Please.

  10. #10
    Registered User
    Join Date
    Oct 2009
    Location
    Noida
    Posts
    941

    Re: EventList program ( how to make an alarm? )

    Try on any Nokia SDK say any S40 5th or 6th edition SDK emulator - you can download it from Nokia website.

    In SUN WTK emulators, these events are stored as vCalendar files with .vcf extensions.

    path may be - C:\Documents and Settings\user\j2mewtk\2.5.2\appdb\DefaultColorPhone\pim\events\Events\*.vcs

    see if these files are created for your event.

    DefaultColorPhone can be replaced by your emulator name.
    Thanks,
    Ekta

  11. #11
    Regular Contributor
    Join Date
    Mar 2010
    Posts
    136

    Re: EventList program ( how to make an alarm? )

    I have installed
    using that emulator, for a same program, sometimes it don't make the alarm voice, I can see the event in the eventlist. It said that the event has been past.
    Sometimes, it doesn't make the alarm voice, but the phone was shaken.
    Sometimes, it makes tha alarm voice and also the viration.

    I don't know why that is happening like that.

  12. #12
    Registered User
    Join Date
    Oct 2009
    Location
    Noida
    Posts
    941

    Re: EventList program ( how to make an alarm? )

    Quote Originally Posted by komomo View Post
    I have installed
    using that emulator, for a same program, sometimes it don't make the alarm voice, I can see the event in the eventlist. It said that the event has been past.
    Sometimes, it doesn't make the alarm voice, but the phone was shaken.
    Sometimes, it makes tha alarm voice and also the viration.

    I don't know why that is happening like that.
    Try this on real device, always set the test meeting time such that it currentime + 5 or 10 mins..else you will get to see the event as passed event.
    Thanks,
    Ekta

  13. #13
    Regular Contributor
    Join Date
    Mar 2010
    Posts
    136

    Re: EventList program ( how to make an alarm? )

    I do not test that program on the real device because I have no real device.
    In fact, I have a mobile phone.
    But after testing a MIDlet on the phone as a first time, my phone does not work any more. The phone screen display nothing since that time.
    Now the phone is in the shop to be repaired and I still have not got that.

    I have decided not to bother ektasrv and other people any more regarding this problem.
    But without your help, I don't know what to do and how to do next.
    So Please help me. and I really appreciate all people's help from the bottom of my heart.

    (1) I have installed Nokia SDK ,S40 5th edition SDK emulator .
    The program does not make the alarm.
    In the calendar, I can see the event I have created.
    The attributes are
    Start date: the date I created the event
    Start time: the time I created the event
    End date: similar with the start date
    End time: similar with start time
    Repeat: never
    Alarm type: silent
    Alarm date: similar with the start date
    Alarm time: ( the time before start time) for example, if the start time is 8:27, the alarm time is 8:12. The program does not make any alarm may be because of that.

    How can I correct that?
    I wrote the program to make the alarm after 2 or 3 min of the current time.

    (2) When I run the program with that sdk , it shows two message box.
    The first one is
    “ Nokia Connecitvity Framework could not set a MAC address.
    Bluetooth between SDK will not be available.
    Terminate all SDKs. Then stop NCF using the system Tray and restart NCF using the start menu."

    What does that message mean?

    The second message is
    "The SDK located java Runtime Environment(JRE) 1.6.0_13.
    Unless you install JRE5, the SDK might not operate properly."

    (3) The message is also appeared in the console.
    "smart card communication error 0x80100017"
    The specified reader is not currently available for use"
    What is the meaning of that message?

  14. #14
    Regular Contributor
    Join Date
    Mar 2010
    Posts
    136

    Re: EventList program ( how to make an alarm? )

    I am really in trouble.
    Please help me if there is anybody who knows how to change the alarm time of Nokia SDK ,S40 5th edition SDK emulator .

  15. #15
    Registered User
    Join Date
    Jan 2010
    Posts
    15

    Re: EventList program ( how to make an alarm? )

    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */

    package newpackage;

    import javax.microedition.midlet.*;
    import javax.microedition.lcdui.*;
    import javax.microedition.io.*;
    import java.util.*;
    import javax.microedition.pim.*;
    import java.io.*;

    /**
    * @author Deepak kinni
    */
    public class CalAlarm extends MIDlet implements CommandListener,Runnable{

    private Display display;
    private Form startDateform,noteform,summaryform,endDateform;
    String note,summary;

    private DateField startDateTime=new DateField("ENTER START DATE:", DateField.DATE_TIME);
    private DateField endDateTime=new DateField("ENTER END DATE:", DateField.DATE_TIME);
    private Date selectedStart;
    private Date selectedEnd;

    private Command exitCommand=new Command("EXIT",Command.EXIT,2);
    private Command okCommand=new Command("NEXT",Command.SCREEN,1);
    private Command cancelCommand=new Command("BACK",Command.BACK,1);
    private Command scheduleCommand=new Command("SCHEDULE",Command.BACK,1);

    private Alert alert,alert1;

    private TextField rem=new TextField("REMINDER NOTE:"," ",100,TextField.ANY);
    private TextField rem1=new TextField("SUMMARY:"," ",100,TextField.ANY);

    long currentDate,scheduledDate;

    String midletClassName = this.getClass().getName();
    Command thCmd;
    Displayable d1;


    public CalAlarm(){}


    public void startApp()throws MIDletStateChangeException {
    try{
    display=Display.getDisplay(this);
    startDateform=new Form("CAL APP");
    startDateform.addCommand(okCommand);
    startDateform.addCommand(exitCommand);
    startDateform.append(startDateTime);
    startDateform.addCommand(scheduleCommand);
    startDateform.setCommandListener(this);
    display.setCurrent(startDateform);

    }catch(Exception e) {
    System.out.println("Exception during startApp()");
    e.printStackTrace();
    // If some kind of transient error ocurrs, throw a
    // MIDledStateChangeException.
    throw new MIDletStateChangeException("Error Starting...");
    }

    }

    void getEndDate()
    {
    display=Display.getDisplay(this);
    endDateform=new Form("CAL APP");
    endDateform.addCommand(okCommand);
    endDateform.addCommand(exitCommand);
    endDateform.append(endDateTime);
    endDateform.setCommandListener(this);
    display.setCurrent(endDateform);
    }
    void getNote()
    {
    display=Display.getDisplay(this);
    noteform=new Form("CAL APP");
    noteform.addCommand(okCommand);
    noteform.addCommand(exitCommand);
    noteform.append(rem);
    noteform.setCommandListener(this);
    display.setCurrent(noteform);
    }

    void getSummary()
    {
    display=Display.getDisplay(this);
    summaryform=new Form("CAL APP");
    summaryform.addCommand(okCommand);
    summaryform.addCommand(exitCommand);
    summaryform.append(rem1);
    summaryform.setCommandListener(this);
    display.setCurrent(summaryform);
    }

    public void createAnEvent() {
    // Create an event entry in the device's local calendar
    // reminding the user to register your application

    PIM pim = PIM.getInstance();
    EventList el = null;
    Event new_event = null;
    try {
    // Open write only since you're just going to
    //add your registration
    // event info to the device's database
    el = (EventList) pim.openPIMList(
    PIM.EVENT_LIST, PIM.WRITE_ONLY);
    } catch (PIMException e) {
    // failed opening the default event list!
    // Error case - abort this attempt
    System.err.println(
    "Error accessing database - aborting action");
    return;
    } catch (SecurityException e) {
    // user rejected application's request
    // for write access to event list
    // This is not an error condition and can be normal
    System.out.println(
    "Okay, this application won't add the event");
    return;
    }
    // Create an "empty" event to work with
    new_event = el.createEvent();
    // Add a registration reminder event:
    if (el.isSupportedField(Event.START)) {
    long l =selectedStart.getTime();
    new_event.addDate(Event.START, PIMItem.ATTR_NONE, l);
    }
    if(el.isSupportedField(Event.END))
    {
    long l1=selectedEnd.getTime();
    new_event.addDate(Event.END,PIMItem.ATTR_NONE, l1);
    }
    if (el.isSupportedField(Event.ALARM))
    new_event.addInt(Event.ALARM, PIMItem.ATTR_NONE,0);
    if (el.isSupportedField(Event.SUMMARY))
    new_event.addString(Event.SUMMARY, PIMItem.ATTR_NONE,
    summary);
    if (el.isSupportedField(Event.NOTE))
    new_event.addString(Event.NOTE, PIMItem.ATTR_NONE,note);
    try {
    // commits it to the list and the native database
    new_event.commit(); // commits it to the list and the native database
    }
    catch (PIMException e) {
    // failed committing the event
    System.err.println("This application cannot add the event");
    }
    try {
    el.close();
    } catch (PIMException e) {
    // failed to close the list
    }
    alert=new Alert("SAVING","SAVING",null,null);
    display.setCurrent(alert,startDateform);


    }
    public void pauseApp() {
    display = null;

    }

    public void destroyApp(boolean uc) {
    display = null;
    try {
    // Set up the alarm and force the MIDlet to exit.
    scheduledDate=selectedStart.getTime();
    System.out.print(scheduledDate);
    System.out.print("\n");
    //scheduledDate=scheduledDate*1000*60;
    System.out.print(scheduledDate);
    try{
    Date alarm = new Date();
    long t1=alarm.getTime();
    System.out.print(t1);
    // String midletClassName = this.getClass().getName();

    long t = PushRegistry.registerAlarm(midletClassName,scheduledDate+10000l);
    }finally{
    destroyApp(true);
    }

    }
    catch(ClassNotFoundException e) {
    System.out.println("Exception during destroyApp()");
    e.printStackTrace();
    }
    catch(ConnectionNotFoundException e) {
    System.out.println("Exception during destroyApp()");
    e.printStackTrace();
    }
    }
    public void commandAction(Command command,Displayable displayable)
    {
    thCmd=command;d1=displayable;
    Thread th = new Thread(this);
    th.start();

    }

    public void run() {
    if(thCmd==okCommand && d1==startDateform)
    {
    selectedStart=startDateTime.getDate();
    getEndDate();
    }
    else if(thCmd==okCommand && d1==endDateform)
    {
    selectedEnd=endDateTime.getDate();
    getNote();
    }
    else if(thCmd==okCommand && d1==noteform)
    {
    note=rem.getString();
    getSummary();
    }
    else if(thCmd==okCommand && d1==summaryform)
    {
    summary=rem1.getString();
    createAnEvent();
    }
    else if(thCmd==scheduleCommand && d1==startDateform)
    {
    notifyDestroyed();
    destroyApp(true);
    }


    }




    }

Similar Threads

  1. Background App tries to make an alarm when phone is locked.
    By idrise in forum Mobile Java General
    Replies: 3
    Last Post: 2009-03-09, 17:17
  2. How can I make a program that can close other program
    By butterflymonkey in forum Symbian
    Replies: 10
    Last Post: 2008-10-08, 13:47
  3. Replies: 6
    Last Post: 2008-07-24, 09:00
  4. can I make alarm In my phone
    By neuralbdr in forum Mobile Java General
    Replies: 0
    Last Post: 2007-12-13, 08:33
  5. I want MAke alarm in my mobile
    By neuralbdr in forum Mobile Java General
    Replies: 0
    Last Post: 2007-10-18, 16:26

Posting Permissions

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