incoming SMS listener test
Hi all. Writing a listener SMS coming that I want to test. But can someone please pass me how I can configure the SDK BB 5 (not the Eclipse plugin) running on Windows 7, so that I can send an SMS to test an emulator to another to see what is happening. Thank you so much as always.
Found answer in another post from Kanaksony. His response was to use 1 emulator with the following:
You need to sms-source port and sms-destination ports even in Simulator. Go to JDE-> Edit-> preferences-> tab-> port sms-source Simulator: 21316 and port destination sms: 21316
Tags: BlackBerry Developers
Similar Questions
-
How to test the SMS listener using 2 emulators in SDK5 running Windows 7
Hi all. Writing a SMS listener I want to test. But can someone please pass me how I can configure the SDK BB 5 (not the Eclipse plugin) running on Windows 7, so that I can send a test SMS from an emulator to another to see what is happening in the debugger. Thank you so much as always.
Found answer in another post from Kanaksony. His response has been to make the source and destination for even 1 emulator ports. His post was:
You need to sms-source port and sms-destination ports even in Simulator. Go to JDE-> Edit-> preferences-> tab-> port sms-source Simulator: 21316 and port destination sms: 21316
-
There are 3 types of ways to listen for incoming sms in the following link:
All those who receive the javax.wireless.messaging.Message for further processing.
I need to check the priority of the message received, which is only available in net.rim.blackberry.api.mail.Message and not javax.wireless.messaging.Message.
Can someone guide me to get the net.rim.blackberry.api.mail.Message When listening for incoming sms?
Thank you.
Net.rim.blackberry.api.mail.Message is actually for mails not for sms
Press the button Bravo thank the user who has helped you.
If your problem has been resolved then please mark the thread as "accepted Solution".
-
How to listen only to the incoming sms message
I want only to hear incoming sms do message not MMA, how.
See this Article.
SMS to notify the application, look at this article.
-
How to detect an incomming SMS? -HELPPPP
Hello everyone,
This is my first post in this forum. So far, it has helped me a lot. But since a few days, I have had a problem. I want to detect an incomming SMS. I read some post and I found a few pieces of codes that are interesting. But, I failed to do so.
Here are a few links I've read:
-http://www.j2mepolish.org/javadoc/j2me/de/enough/polish/messaging/MessageListener.html
I will stop here with links.
Now, here is my code:
/* * hw.java * * ©
, 2003-2008 * Confidential and proprietary. */ import java.util.*; import java.lang.*; import java.io.*; import java.io.IOException; import javax.microedition.location.*; import javax.microedition.io.*; import javax.microedition.io.file.*; import javax.microedition.pim.*; import javax.wireless.messaging.*; import net.rim.device.api.io.*; import net.rim.device.api.ui.*; import net.rim.device.api.ui.component.*; import net.rim.device.api.ui.container.*; import net.rim.device.api.system.*; import net.rim.device.api.i18n.*; import net.rim.blackberry.api.invoke.*; /** * */ class hw extends UiApplication { public static void main(String[] args) { hw instance = new hw(); instance.enterEventDispatcher(); } public hw() { pushScreen(new SalutationScreen()); } } class SalutationScreen extends MainScreen implements Runnable //, MessageListener { private Thread t; private MessageConnection _mc; public SalutationScreen() { super(); LabelField applicationTitle = new LabelField("Hello World Title"); setTitle(applicationTitle); RichTextField helloWorldTextField = new RichTextField("Hello World!"); add(helloWorldTextField); t = new Thread(this); t.start(); /* try { _mc = (MessageConnection)Connector.open("sms://:0"); _mc.setMessageListener(this); helloWorldTextField = new RichTextField("setMessageListener : done"); add(helloWorldTextField); } catch (IOException e) { helloWorldTextField = new RichTextField("erreur constructeur : " + e); add(helloWorldTextField); } */ } public boolean onClose() { Dialog.alert("Bye World!"); System.exit(0); return true; } public void run() { try{ DatagramConnection _dc = (DatagramConnection)Connector.open("sms://:0"); for(;;) { Datagram d = _dc.newDatagram(_dc.getMaximumLength()); _dc.receive(d); byte[] bytes = d.getData(); String address = d.getAddress(); String msg = new String(bytes); helloWorldTextField = new RichTextField(" Message text received : " + msg ); add(helloWorldTextField); } } catch(Exception e){} /* METHOD 2 while(true) { try { DatagramConnection _dc = (DatagramConnection)Connector.open("sms://"); Datagram d = _dc.newDatagram(_dc.getMaximumLength()); _dc.receive(d); String address = new String(d.getAddress()); String msg = new String(d.getData()); helloWorldTextField = new RichTextField("Message received: " + msg + "\n" + address); add(helloWorldTextField); Alert.startVibrate(3000); } catch (IOException e) { System.err.println(e.toString()); } } */ /* METHOD 3 try { MessageConnection _mc = (MessageConnection)Connector.open("sms://:0"); for(;;) { Message m = _mc.receive(); String address = m.getAddress(); String msg = null; if ( m instanceof TextMessage ) { TextMessage tm = (TextMessage)m; msg = tm.getPayloadText(); } else if (m instanceof BinaryMessage) { StringBuffer buf = new StringBuffer(); byte[] data = ((BinaryMessage) m).getPayloadData(); // convert Binary Data to Text msg = new String(data, "UTF-8"); } else System.out.println("Invalid Message Format"); RichTextField helloWorldTextField = new RichTextField("Received SMS text from " + address + "\n" + msg); add(helloWorldTextField); } } catch (IOException e) { System.err.println(e.toString()); } */ } /* METHOD 4 public void notifyIncomingMessage(MessageConnection conn) { RichTextField helloWorldTextField = new RichTextField("notifyIncomingMessage DEBUT"); add(helloWorldTextField); try { Message m = conn.receive(); helloWorldTextField = new RichTextField("- Message recu"); add(helloWorldTextField); String address = m.getAddress(); String msg = null; if ( m instanceof TextMessage ) { TextMessage tm = (TextMessage)m; msg = tm.getPayloadText(); } else if (m instanceof BinaryMessage) { StringBuffer buf = new StringBuffer(); byte[] data = ((BinaryMessage) m).getPayloadData(); // convert Binary Data to Text msg = new String(data, "UTF-8"); } else System.out.println("Invalid Message Format"); helloWorldTextField = new RichTextField("- Message de : " + address + " // \""+ msg + "\""); add(helloWorldTextField); } catch (IOException e) { helloWorldTextField = new RichTextField("erreur _mc.receive : " + e); add(helloWorldTextField); } } */ /* METHOD 5 public void notifyIncomingMessage(MessageConnection messageConnection) { new Thread() { MessageConnection conn; Thread set(MessageConnection conn) { this.conn = conn; return (this); } public void run() { try { Message m = conn.receive(); String msg = null; if ( m instanceof TextMessage) { TextMessage tm = (TextMessage) m; msg = tm.getPayloadText(); RichTextField helloWorldTextField = new RichTextField("- Message de : " + m.getAddress() + " // \""+ msg + "\""); this.add(helloWorldTextField); } } catch (Exception e) { } } }.set(messageConnection).start(); } */ } In my code, I tested 5 methods. But, I think that all of them blocked the line where there is method of 'received() '.
If there is someone who can help me find my problem, it's going to be great. (Or if there is someone who wants to send me a complete code that works, it will be better than the grand )
Thank you for all the answers.
I agree with you. It's better if I post a solution.
I have re-written some other program that gets the phone number and the content of the incomming SMS.
Here is my code
public class smsReceived extends UiApplication { private LabelField _status; private DatagramConnection _dc; public static void main(String[] args) { new smsReceived().enterEventDispatcher(); } public smsReceived() { super(); waitASms(); } public void waitASms() { try { _dc = (DatagramConnection)Connector.open("sms://"); for(;;) { Datagram d = _dc.newDatagram(_dc.getMaximumLength()); _dc.receive(d); String address = new String(d.getAddress()); String msg = new String(d.getData()); } } catch (IOException e) { System.err.println(e.toString()); } } }
In this code, the string 'address' is the phone number and the string 'msg' is the content.
To view, please do another method with this channels.
Next time.
-
Hi - just wondering if he had plans to make available a way to implement a SMS listener for incoming SMS messages / outgoing (this was possible on the old Java SDK). I don't see anything equivalent in the latest SDKS, neither on the road map.
Thanks in advance :-)
Hello
in fact, we already support something very similar to the listeners of the Java platform.
SMS is part of the PIM API and the key classes
bb::pim::message::SmsTransport.
This class allows (among other things) registration for incoming SMS messages addressed to a specific port. You will receive SMS messages to port and be able to extract their payload as a byte array. The class uses Qt signals and slots, so it is quite easy to use. Here are a few snippets of code to help you get started:
in the header
public slots: void onMessageReceived(unsigned int, const Message &); void onRegisterResultReceived(unsigned int port, bb::pim::message::SmsTransportRegistrationResult::Type status ); private: bb::pim::message::SmsTransport* _sms_transport;
in the source of the CPP, my class called SmsReceiver:
SmsReceiver::SmsReceiver(bb::cascades::Application *app) : QObject(app), _initialised_ok(false), _sms_transport(new bb::pim::message::SmsTransport(this)) { connect(_sms_transport, SIGNAL(registerResultReceived (unsigned int, bb::pim::message::SmsTransportRegistrationResult::Type)), this, SLOT(onRegisterResultReceived(unsigned int, bb::pim::message::SmsTransportRegistrationResult::Type))); connect(_sms_transport, SIGNAL(messageReceived (unsigned int, const Message &)), this, SLOT(onMessageReceived(unsigned int, const Message &))); // registering to receive SMS messages addressed to port 16000 _sms_transport->registerPort(16000); } void SmsReceiver::onRegisterResultReceived(unsigned int port, bb::pim::message::SmsTransportRegistrationResult::Type status) { if (status == 1) { log(QString("Port %1 registered OK").arg(port)); } else { log("Failed to register port:" + status); log("Error:" + getResultReceivedName(status)); } } void SmsReceiver::onMessageReceived(unsigned int port, const Message& message) { // the short_message payload is an Attachment to the PIM Message object and the .data() method returns it as a byte array bb::pim::message::Attachment attachment = message.attachmentAt(0); hexlog(attachment.data()); }
Key points:
- registration will succeed or fail, and you must use the registerResultReceived signal to receive the notification of the result of this step.
- When a message to your registered port is received by the operating system, a signal messageReceived sounds then you must connect one of your methods of this signal. Your slot will receive a Message object. The attribute short_message of the SMS ("short_message" by GSM 03.40) will be given an object attachment associated with the subject of the Message. Retrieves the attachment object and call the data() function to get short_message as a byte array. Note that to properly decode the array of bytes that you really know his what data_coding value has been used when you create and send the SMS message and whether or not a header (UDH) user data is present.
I hope this helps.
Martin
-
SMS for outgoing SMS listener throws IOException immediately after the open call
I had already created a class for sending SMS messages which worked perfectly until I added the listener. When the listener is added as soon as I start the thread throws an IOException exception who am I hurting? The only thing I can think is some kind of wire problem, please help.
Here's the SMS & Listener class:
private static final class SmsMessage { private String _address; private String _msg; public SmsMessage(String address, String msg) { _address = address; _msg = msg; } public Message toMessage(MessageConnection mc) { TextMessage m = (TextMessage)mc.newMessage(MessageConnection.TEXT_MESSAGE,"sms://" + _address); m.setPayloadText(_msg); return m; } } // SmsMessage private final class SendThread extends Thread { private static final int TIMEOUT = 500; // ms private Vector _msgs = new Vector(10); // Queue of 10 private volatile boolean _start = false; // queue requests public synchronized void send(String address, String msg) { _start = true; _msgs.addElement(new SmsMessage(address, msg)); } public synchronized void stop() { _stop = true; try { if ( _mc != null ){ _mc.close(); } } // catch (IOException e ) { catch (Throwable t) { t.printStackTrace(); System.exit(0); } } public void run() { try { //closed by the stop() method _mc = (MessageConnection)Connector.open("sms://"); if (_mc != null) { // set a listener to trap outgoing sms messages _mc.setMessageListener(new OutboundSMSListener()); } for(;;) { while( !_start && !_stop) { try { sleep(TIMEOUT); } // catch (InterruptedException e) { catch (Throwable t) { t.printStackTrace(); System.exit(0); } } if ( _stop ) { return; } while(true) { try { SmsMessage sms = null; synchronized (this) { if ( !_msgs.isEmpty() ) { sms = (SmsMessage)_msgs.firstElement(); // take it out of the queue once we sent it _msgs.removeElement(sms); } else { _start = false; break; } } _mc.send(sms.toMessage(_mc)); } // catch (IOException e) { catch (Throwable t) { t.printStackTrace(); System.exit(0); } } } } // catch (IOException e) catch (Throwable t) { t.printStackTrace(); System.exit(0); } } } // SendThread private static final class OutboundSMSListener implements OutboundMessageListener { public void notifyIncomingMessage(MessageConnection messageconnection) { // we don't care about incoming sms messages right now } public void notifyOutgoingMessage(Message message) { Dialog.alert("Detected An Outgoing SMS Event"); } }
Thank you. Makes sense.
-
Hello
I have two iPhones one is version 5 and the second is 5 s version.
Both are updated to the latest version of iOS.
In my worm. 5 s when entering SMS comes the iPhone gives alert music.
The problem is with another iPhone 5 that when entering SMS happens no sounds are heard.
I tried to compare the configurations, but found no difference between the two.
I have to lack the question.
Where can I configure the iPhone 5 to produce music for the arrival of incoming SMS alert.
Thank you
I would add: no mute is on. It is not Nothing disturbs mode
Try updating to the latest iOS
Also try to put in a different sound for text in settings - sounds
Force restart the phone and see if the SMS produced the new sound
-
Hi all
I put in place of the SMS listener and I am able to get the device number but I'm not able to get the name of the contact to shippers. Any one know how to get contact name of entrants and SMS-password.
Thank you
got the solution here:- recover contacts by phone number
-
deleting incoming sms in the Inbox
Anyone know how to remove sms all inbox.
I can't find a solution in the API.
Not that new look or sms outgoin.
Never click on a URL from the tiny type that you never know where he's going to do. If you trust the site, never click on the links to the full URL:
http://supportforums.BlackBerry.com/T5/Java-development/deleting-incoming-SMS-from-Inbox/TD-p/592620
AndreyMM,
He doesn't know the rest of the code. Try searching Google or even Crackberry post as they usually come from assets
-
Intercept specific incoming SMS
Is it possible to intercept specific incoming SMS?
Ex:
I want to intercept all the SMS phone number + 1234567890
Welcome on the support forums.
Please use the search box at top right, it would give you results can be used as http://supportforums.blackberry.com/t5/Java-Development/Block-sms-from-specific-number/m-p/1348097#M...
-
OK, I could read/catch all incoming sms using a small piece of code but all these sms are also in the sms Inbox as unread.
How can I mark as read?
You cannot programmatically change the SMS Inbox.
-
FileSystemJournalListener and incoming SMS do not work together
I need the two lisnner in my incoming sms app and added file listner
SMS module
and the listner added file is
Application appInstance = Application.getApplication ();
screen filesystemJournalListener = new filesystemJournalListener();
appInstance.addFileSystemJournalListener (screen);both work very well sapratly but if I put the two together only sms worked listner file you added, but not work
Please help and sorry for the bad English
You put the interface of the camera in a Thread, and not the SMS interface.
-
listen to incoming sms does not
I am currently listening to incoming binary sms in a particular port. I am able to do this. But the problem is that, if I print the msg in the console, its empty display, but the chain even if I call a dialog.alert, it displays in the dialog box. Help, please.
Hello
Here go us
public boolean onClose() {}
UiApplication.getUiApplication () .requestBackground ();
Returns true;
} -
Hi, I'm new to the development of Blackberry, I read everything on the application running at startup and have a different point of entry for this application. I still need help with my application
I use BB JDE 4.7
Simulator: BB 9530 4.7.0
I'm developing an application of SMS. (extends UiApplication)
1) there is a thread that listens for incoming messages
2) there is a wire which is a SMS sender
3) there is a main screen and two full screens. for example, when the user clicks a button in one of the screens full... I send you a message
(4) when a message is received, based on the content of the message I push either a full screen
(5) I have, all the wires and screens as the class internal to the main class that extends from the UiApplication.
I got the basic features. I need help making that demand the application of autostartup
(1) I need to start listening to the sms thread when the BB phone starts
(2) I need to have the application icon in the applications screen as another entry point for the application (only for the GUI), and the listening thread must remain active in the background.
(3) when an incoming message is detected, the application GUI should be brought to the foreground (if it isn't already forground) after posting a popup (instead of bring the application to the foreground, is it better to display a flashing icon in the status bar of the home screen blackberry and perhaps global popup)
(4) when the GUI of the application part is closed, I need to stop the sms sending thread, and when the system shuts down, I need to stop the listening thread.
Please help me guys... I have read many articles and discussions regarding the automatic start-up of applications, another point of entry, the # of background threads...
but I couldn't find how to implement my needs.
(1) should I need to create two different projects (applications [GUI thread, a sender] and one for the listening thread)? or I can achieve in single application?
(2) should I have to sign in the background thread to the GUI app? If so, how?
(3) it is necessary to use the RunTimeStore object? If so, I don't know how I can bring to the foreground the application GUI of the background thread.
(4) if I have to stop the thread of listening by overiding onExit() method, the important question I have is, if the onExit() method is only for applications that extends from the Application class and not for the UiApplication class?
(5) if I should have two projects (one main and the other as a spare point entry), which project should I do as "autorun at startup" and a "system module".
As I need to have the background still running thread when the GUI application is active. I don't know how I do.
Hello world...
I reached my needs thanks to a single application. I used an other entry point.
To refer to chk my other post
Maybe you are looking for
-
e-mail from apple about purchase
I've received an email like that of [email protected]. I think it's not mine. I did not have any purchase like this. the name of my phone is not it. I don't know lydias phone. When ı click on 'Cancel and manage subscriptions"icon ı see
-
What is happening on our internal websites used to ask for a window to enter your credentials. This is not is no longer the case. It comes immediately gives us a 401-Unauthorized: access is denied due to credentials not valid.You don't have permissio
-
Apple music - how to remove audio files from my iPhone 6
Am using Apple's music, also have a library of large 20,000 + iTunes (saved with iTunes game). Before the launch of music Apple had a number of elements (693) downloaded to the phone. No need to have too much space. Tried to remove it from iTunes
-
Hello Is it possible to change the name of track of legend in a chart of the band? If so, how? Example: replace "Track 1" name "moisture sensor". Thank you
-
Security for Microsoft Works 9 (KB2680317) cannot install update
original title: update of security for Microsoft Works 9 (KB2680317) I tried to update the following, but he missed three days in a row - other updates succeeded:Update of security for Microsoft Works 9 (KB2680317)