Sign in

Push Api, Open Your Application On Push

 
Print Email
Sr Software Engineer
J2ME Push API :

It's a very powerful concept to receive some information asynchronously on particular port, instead of forcing the application to use synchronous polling techniques.
It is introduced on MIDP 2.0 (JSR 118).
How to invoke application:

Initially your application is on sleep mode. As soon as any push message comes to a particular port which is register for push messages, in place of moving into inbox, it invokes the application first.
It makes an alternate entry point for application to invoke it.
It does not make any change in application life cycle, but only creates an alternative way to start your application without invoking by user.
fig 2
It's responsibility shared between AMS and MIDlet, which is split as :
1 : When MIDlet is on sleep : AMS monitors the push event continuously. When any push message hit the registered port, AMS invokes the appropriate MIDlet to handle it.
2 : When MIDlet is running : MIDlet directly handles the push event.
//This code execute when MIDlet activates by push
public void messageReceivedHandler (TextMessage receivedMessage) {
String senderAddress = receivedMessage.getAddress();
String receivedMessageBody = "No msg received as yet";
//Receives the text message from sms
receivedMessageBody = receivedMessage.getPayloadText();
System.out.println("Received Message = "+receivedMessageBody);
}
/**
* Notification that a message arrived.
* @param conn the connection with messages available
*/
public void notifyIncomingMessage(MessageConnection conn) {
if ((thread == null) || (conn == smsconn)) {
done = false;
thread = new Thread(this);
thread.start();
System.out.println("Notify Incoming Message received..");
}
else
System.out.println("Incoming Msg, but thread is alive");
}
Sign Up For a Roundup of The Week's Top Bloggers
Email:
SiliconIndia About Us   |   Contact Us   |   Help   |   Community rules   |   Advertise with us   |   Sitemap
News:       Technology   |   Enterprise   |   Tech Products   |   Startups   |   Finance   |   Business   |   Career   |   Magazine  |   Dailydose   |   News archive  
Cities:         Startup   |   CIO   |   Cloud   |   QA   |   BI   |   Women   |   Finance   |   Real Estate   |   Gadgets   |   Travel   |   HR   |   Marketing   |   SME  
Network:      Network   |   Profile   |   Messages   |   Find   |   Blogs   |   Events   |   Q&A   |   CXO Insights  
Career:      Jobs   |   Companies   |   Mentorship   |   Videos   |   Career blogs  |   Training Institute  |   Freshers
Online courses:   Web developer   |   Java developer   |   CCNA training   |   SEO   |   SAS   |   SQL server 2005   |   J2EE
Education:   MBA   |   MCA   |   Engineering   |   Overseas Education   |   Internship
Life:           Jokes   |   Bookstore   |   Relocate  |   Marketplace
Send your and help us continue to improve SiliconIndia
© 2012 SiliconIndia all rights reserved