






































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
An overview of java me (mobile edition) and its use in wireless messaging and bluetooth technology. It covers the wireless messaging api (jsr205) for sending and receiving sms messages, as well as the basics of bluetooth, including discovering devices and services, and creating bluetooth clients and services. The document also includes examples of using the wma console in netbeans for sending and receiving messages, and creating a bluetooth service and client.
Typology: Study notes
1 / 46
This page cannot be seen from the preview
Don't miss anything!
1
Sent through a store-and-forward network
Messages are sent and received using a MessageConnection The javax.wireless.messaging package contains classes for sending and receiving messages Message is an interface These are subinterfaces
Sending a message Receiving a message
Select the Wireless Toolkit Go to the Tools & Extensions tab Click the Open Utilities button
Select and click Launch
E.g. +
E.g. +5550000:
import javax.microedition.midlet.; import javax.microedition.lcdui.; import javax.wireless.messaging.; import javax.microedition.io.Connector; public class SendMidlet extends MIDlet implements CommandListener, Runnable{ private Form mForm; private StringItem lblMessage; private TextField txtDest, txtMsg; ... } Importing packages required for messaging Displays a success / failure message To specify the destination number For entering the message to be sent*
public void commandAction(Command c, Displayable s) { if (c.getCommandType() == Command.EXIT) { notifyDestroyed(); } else { lblMessage.setText("Sending SMS..."); Thread t = new Thread(this); t.start(); } } Starts a new thread so that our GUI doesn’t hang when we send a message – this is why our MIDlet implements Runnable
public void run(){ try { MessageConnection conn = (MessageConnection) Connector.open("sms://" + txtDest.getString()); TextMessage txtMessage = (TextMessage) conn.newMessage(MessageConnection.TEXT_MESSAGE); txtMessage.setPayloadText(txtMsg.getString()); conn.send(txtMessage); lblMessage.setText("SMS sent successfully"); conn.close(); } catch(Exception ex) { lblMessage.setText("Message could not be sent"); } } The Connector creates the correct connection for the given protocol We are sending an SMS in text format Sets the text to be sent Sends the message Whenever we deal with external resources, we should use try…catch
Sends a message Receives a message
import javax.microedition.midlet.; import javax.microedition.lcdui.; import javax.wireless.messaging.; import javax.microedition.io.Connector; public class ReceiveMidlet extends MIDlet implements CommandListener, Runnable{ private Form mForm; private StringItem lblMessage; private TextField txtPort; private boolean finished; ... } Importing packages required for messaging Displays received messages Used to keep displaying received messages until MIDlet is closed For entering the port to listen on*