×

Discussion Board

Results 1 to 12 of 12
  1. #1
    Registered User
    Join Date
    Feb 2013
    Location
    Madrid
    Posts
    84

    Notifications in Nokia S40 SDK 2.0

    Hi all!

    I need to show some notification messages in my app, developed with the Nokia SDK 2.0. I can't find any info about it or any example to know what to do it.
    Does anyone know how to do that?

    I don't need to work with notification push or nothing like that. Only show messages in the notification bar.

  2. #2
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    602

    Re: Notifications in Nokia S40 SDK 2.0

    Can you try and explain in more details what are you trying to do? i'm having trouble understanding.

    Are you developing an app using SDK 2.0 that runs on Asha FT device or New Asha device?
    what kind of messages are you trying to show? within your app or within the phone UI?
    are the messages coming from your app? the network? sms? your server?
    Heard of DVLUP? Join here

  3. #3
    Registered User
    Join Date
    Feb 2013
    Location
    Madrid
    Posts
    84

    Re: Notifications in Nokia S40 SDK 2.0

    I'm developing a S40 app with the SDK 2.0, for the 305 and 311 devices.

    I need to set some alarms in the app, and when it's the time set by the alarm, the device must show a message (like a notification, if it's possible in the status bar, like android or iOS)

    Is it more clear now?

    Thanks

  4. #4
    Nokia Developer Champion
    Join Date
    Mar 2013
    Posts
    602

    Re: Notifications in Nokia S40 SDK 2.0

    Heard of DVLUP? Join here

  5. #5
    Registered User
    Join Date
    Aug 2011
    Posts
    39

    Re: Notifications in Nokia S40 SDK 2.0

    Depending on what you are after, you can also add an event to the device calendar with an alarm. That will show
    a message at a specific time to the user. Something like this (simplified, add error checking, etc)

    eventList = (EventList) PIM.getInstance().openPIMList(PIM.EVENT_LIST, PIM.READ_WRITE);
    Event event = eventList.createEvent();

    event.addString(Event.SUMMARY, PIMItem.ATTR_NONE, p.getTitle());
    event.addDate(Event.START, PIMItem.ATTR_NONE, p.getStartTime().getTime());
    event.addString(Event.NOTE, PIMItem.ATTR_NONE, p.getSynopsis());
    event.addDate(Event.ALARM, PIMItem.ATTR_NONE, p.getStartTime().getTime() - 60000);

    event.commit();
    eventList.close();

  6. #6
    Registered User
    Join Date
    Feb 2013
    Location
    Madrid
    Posts
    84

    Re: Notifications in Nokia S40 SDK 2.0

    What is the p variable that you are using for everything?

  7. #7
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,568

    Re: Notifications in Nokia S40 SDK 2.0

    Quote Originally Posted by Javier Muñoz View Post
    What is the p variable that you are using for everything?
    That simply does not matter.
    What matters is that the
    - first line is event.addString with Event.SUMMARY. So that is going to be the description of the event, and p.getTitle() presumably produces a String
    - second line is event.addDate with Event.START. So this is the actual schedule for the event. p.getStartTime().getTime() might produce some kind of Data object, or maybe a simple number(*)
    - third line is event.addString with Event.NOTE. This is probably a short String, maybe one line about the event. p.getSynopsis() most probably produces a String
    - fourth line is event.addDate with Event.ALARM. This seem to set the alarm, presumably to some time before the event occurs. The 60000 seems to be 60*1000, so maybe it is milliseconds and the resulting alarm is set 1 minute (60 seconds) before the event.
    These are some obvious guesses. Then you can check the documentation, http://developer.nokia.com/Resources...pim/Event.html. Apparently I mixed SUMMARY and NOTE, so SUMMARY is the short and NOTE is the long description. And addDate really works with milliseconds.

  8. #8
    Registered User
    Join Date
    Feb 2013
    Location
    Madrid
    Posts
    84

    Re: Notifications in Nokia S40 SDK 2.0

    Using this methods give me an UnsupportedFieldException 104.....wow?

  9. #9
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Budapest, Hungary
    Posts
    28,568

    Re: Notifications in Nokia S40 SDK 2.0

    Here is a more complete example: http://developer.nokia.com/Community...ent_in_Java_ME - apparently it uses isSupportedField calls to avoid usage of non-supported fields.

  10. #10
    Registered User
    Join Date
    Aug 2011
    Posts
    39

    Re: Notifications in Nokia S40 SDK 2.0

    Quote Originally Posted by Javier Muñoz View Post
    What is the p variable that you are using for everything?
    That is just my private object that contains the relevant information, it is up to you how you deal with the various string and times you need for the event.

    And yes, you need to check what fields are supported by your particular device, so for every event field you need to do a:

    if (eventList.isSupportedField(Event.START) == true)
    // can use field
    else
    // can not use the field

    test.

  11. #11
    Registered User
    Join Date
    Feb 2013
    Location
    Madrid
    Posts
    84

    Re: Notifications in Nokia S40 SDK 2.0

    I've been following this page to build my events http://developer.nokia.com/Resources...pim/Event.html, but when I have tried to add the alarm time, it gives me an error "An internal error occurred: javax.microedition.pim.FieldFullException.

    I've created the note with the summary and the start and end time, but I need to puto on the alarm.

    Here is my test code:

    Code:
    package mobileapplication2;
    
    import com.sun.lwuit.Command;
    import com.sun.lwuit.Display;
    import com.sun.lwuit.Form;
    import com.sun.lwuit.Label;
    import com.sun.lwuit.events.ActionEvent;
    import java.util.Date;
    import javax.microedition.io.ConnectionNotFoundException;
    import javax.microedition.io.PushRegistry;
    import javax.microedition.midlet.*;
    import javax.microedition.pim.Event;
    import javax.microedition.pim.EventList;
    import javax.microedition.pim.PIM;
    import javax.microedition.pim.PIMException;
    import javax.microedition.pim.PIMItem;
    
    /**
     * @author S40
     */
    public class Midlet extends MIDlet implements Runnable {
    
        Midlet m;
        Form f;
    
        public Midlet() {
            Display.init(this);
            m = this;
        }
    
        public void startApp() {
            Display.getInstance().callSerially(this);
        }
    
        public void pauseApp() {
        }
    
        public void destroyApp(boolean unconditional) {
        }
    
        public void run() {
            try {
                System.out.println("NOW " + new Date().getTime());
                long l = PushRegistry.registerAlarm(getClass().getName(), System.currentTimeMillis() + 100000);
                Date d = new Date();
                d.setTime(System.currentTimeMillis() + 100000);
                System.out.println("NOW " + d.toString());
                f = new Form("Example");
    
                Command back = new Command("back") {
                    public void actionPerformed(ActionEvent evt) {
                        f.showBack();
                    }
                };
                f.setBackCommand(back);
    
                EventList eventList = (EventList) PIM.getInstance().openPIMList(PIM.EVENT_LIST, PIM.READ_WRITE);
                Event event = eventList.createEvent();
                f.addComponent(new Label("HELLO"));
                if (eventList.isSupportedField(Event.START)) {
                    f.addComponent(new Label("START"));
                    event.addDate(Event.START, PIMItem.DATE, d.getTime());
                }
                if (eventList.isSupportedField(Event.END)) {
                    f.addComponent(new Label("END"));
                    event.addDate(Event.START, PIMItem.DATE, d.getTime());
                }
                if (eventList.isSupportedField(Event.ALARM)) {
                    f.addComponent(new Label("ALARM"));
                    event.addInt(Event.ALARM, PIMItem.ATTR_NONE, 600);
                }
                if (eventList.isSupportedField(Event.SUMMARY)) {
                    f.addComponent(new Label("SUMMARY"));
                    event.addString(Event.SUMMARY, PIMItem.ATTR_NONE, "Meeting with John");
                }
                event.commit();
                eventList.close();
    
                f.show();
            } catch (PIMException ex) {
                ex.printStackTrace();
            } catch (ClassNotFoundException ex) {
                System.out.println("NOT FOUND");
                ex.printStackTrace();
            } catch (ConnectionNotFoundException ex) {
                System.out.println("CONNECTION");
                ex.printStackTrace();
            }
        }
    }
    I've tried to add a date to the ALARM event, but it doesn't work. In the documentation says:

    ALARM

    public static final int ALARM
    Field specifying a relative time for an Alarm for this Event. Data for this field is expressed with an int data type. The alarm is expressed in seconds and derived by subtracting the alarm value from every date/time occurrence of this Event. For example, if this field has a value of 600, then the alarm first occurs 600 seconds before the date/time value specified by Event.START. For reoccurrences of the event, the alarm is calculated by substracting the stored value from the date/time of the specific event occurrence.
    Note that the value provided may be rounded-down by an implementation due to platform restrictions. For example, should a native Event database only support alarm values with granularity in terms of minutes, then the provided alarm value is rounded down to the nearest minute (e.g. 636 seconds would become 600 seconds).

  12. #12
    Registered User
    Join Date
    Feb 2013
    Location
    Madrid
    Posts
    84

    Re: Notifications in Nokia S40 SDK 2.0

    I've got to write events in my calendar but what I haven't get is to set the event sound. I mean the events in the calendar have an option, to have sound or not.

    I don't find the way to set it on!

    Thanks

Similar Threads

  1. Replies: 3
    Last Post: 2013-02-21, 12:56
  2. Notifications API and Qt 4.7.1/Qt 4.6.3
    By symbi4n_programmer in forum [Archived] Qt SDKs and Tools
    Replies: 6
    Last Post: 2011-01-25, 09:38
  3. Nokia E72 = No email new messages notifications=
    By cslinux in forum General Messaging
    Replies: 1
    Last Post: 2010-09-22, 06:16
  4. Turning off Unsolicited SMS notifications from the Nokia SMSC
    By alanskinner in forum General Messaging
    Replies: 0
    Last Post: 2003-07-22, 16:23

Posting Permissions

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