Please note that as of October 24, 2014, the Nokia Developer Wiki will no longer be accepting user contributions, including new entries, edits and comments, as we begin transitioning to our new home, in the Windows Phone Development Wiki. We plan to move over the majority of the existing entries. Thanks for all your past and future contributions.

Revision as of 15:55, 2 June 2008 by kiran10182 (Talk | contribs)

How to create birthday alarm in Java ME

From Wiki
Jump to: navigation, search

You have the same problem like me and you also forgot the birthday of your friends or family members so here is the solution from my side.

First save your friend's name, mobile no. and date of birth in the contact list. after that using pim api we create a function.

void contactlist(){
PIM pim = PIM.getInstance();
ContactList contactList = null;
try {
contactList =
Enumeration en;
en = contactList.items();
Contact contact;
contact = (Contact)en.nextElement();

catch( PIMException pimEx ){
// no contact list available!
System.out.println("EX - No contact list available.");
catch( SecurityException securityEx){
// the application is not allowed to access the list
System.out.println("EX - Access denied.");

And another function for sending sms.

public void sendSms(){
String message="happy birthday"+name;
boolean result = true;
try {
//sets address to send message
String addr = "sms://"+number;
// opens connection
MessageConnection conn = (MessageConnection);
// prepares text message
TextMessage msg =
//set text
// send message
} catch (Exception e) {
result = false;
return result;

And for launching midlet everyday we use alarm.

String connURL = "sms://";
String MIDletStr = "name_of_the_midlet";
String FilterStr = "*";
try {
MIDletStr, FilterStr);
} catch ( ClassNotFoundException cnf ) {
} catch ( IOException ioe ) {
long prevalarm;
String MIDletname = "AlarmMIDlet";
Date nexttime = new java.util.Date() + 60000*60*24;
prevalarm = PushRegistry.registerAlarm( MIDletname, nexttime );

Create a midlet that will run with the help of alarm. In this midlet compare the current date and month with the pim item list If there is a compare, assign friends name to the name variable. and call the sendsms() method that will send this message to the selected friend's mobile no and also display an alert to notify that one message is send to the xyz friend for his birthday.

31 page views in the last 30 days.