You Are Here:

Community: Wiki

This page was last modified on 13 September 2009, at 06:22.

How to create birthday alarm in Java ME

From Forum Nokia Wiki

Reviewer Approved   
Reviewer Approved   

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 =
(ContactList)pim.openPIMList(PIM.CONTACT_LIST,PIM.READ_WRITE );
Enumeration en;
en = contactList.items();
Contact contact;
while(en.hasMoreElements())
{
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) Connector.open(addr);
// prepares text message
TextMessage msg =
(TextMessage)conn.newMessage(MessageConnection.TEXT_MESSAGE);
//set text
msg.setPayloadText(message);
// send message
conn.send(msg);
conn.close();
} catch (Exception e) {
result = false;
}
return result;
}
}


And for launching midlet everyday we use alarm.

import	javax.microedtion.io.PushRegistry;
...
 
String connURL = "sms://";
String MIDletStr = "name_of_the_midlet";
String FilterStr = "*";
 
try {
PushRegistry.registerConnection(connURL,
MIDletStr, FilterStr);
} catch ( ClassNotFoundException cnf ) {
...
} catch ( IOException ioe ) {
...
}
...
 
 
 
import javax.microedtion.io.PushRegistry;
...
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.

do you want to create a custom item like a list with marquee list items or a filtered list. just read this article Custom List item with marquee effect http://www.vimviv.com/kb.php?id=17

Related Wiki Articles

No related wiki articles found

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia 
RDF Facets: qdcZidentifierQSxhttpE3aE2fE2fwikiE2eforumE2enokiaE2ecomE2findeE78E2ephpE2fTalkE3aE4cargeE5fscreenE5fsaverX qdcZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qdcZtypeQUqfntypeZCommunityContentQ qdcZtypeQUqfntypeZE52esourceQ qdcZtypeQUqfntypeZWebpageQ qdcZtypeQUqfntypeZWikiContentQ qdcZtypeQUqmarsZManagedE52esourceQ qdcZtypeQUqwebZInformationE52esourceQ qdcZtypeQUqwebZPageQ qdcZtypeQUqwebZE52esourceQ qdcZtypeQUqrdfsZE52esourceQ qfnZtypeQUqfntypeZCommunityContentQ qfnZtypeQUqfntypeZE52esourceQ qfnZtypeQUqfntypeZWebpageQ qfnZtypeQUqfntypeZWikiContentQ qmarsZlanguageQUxhttpE3aE2fE2fswE2enokiaE2ecomE2flanguageE2d1E2fenX qrdfZtypeQUqfnZE45E78cludedFromGeneralE4cistingsQ qrdfZtypeQUqfntypeZCommunityContentQ qrdfZtypeQUqfntypeZE52esourceQ qrdfZtypeQUqfntypeZWebpageQ qrdfZtypeQUqfntypeZWikiContentQ qrdfZtypeQUqmarsZManagedE52esourceQ qrdfZtypeQUqwebZInformationE52esourceQ qrdfZtypeQUqwebZPageQ qrdfZtypeQUqwebZE52esourceQ qrdfZtypeQUqrdfsZE52esourceQ
User Rating: qfnZuserE5FratingQNx3E2E0000X