How different incoming sms to mms?
Hi, I have a problem with grateful ig sms or mms came. I have this code:
public void incomingSms(){ try{ MessageConnection _sms = (MessageConnection) Connector.open("sms://:0"); _sms.setMessageListener(this); }catch(Exception e){} }//end of incomingSms() method public void notifyIncomingMessage(MessageConnection _ms){ try{ _ms.receive(); Dialog.alert("sms came"); }catch(Exception e){} }//end of notifyIncomingMessage() method
but here - either an sms or mms came in i've got this alert "sms has come." When I try to apply the same code but using:
MessageConnection _mms = (MessageConnection)
Connector.Open("MMS://:0");
I don't get an alert (or mms or sms) it seems that he didn't get the message.
What is the problem with my implementation doesn't corectlly?
Kind regards
_Ms.recieve () returns the Message, you can check this Message is the text body and differentiate.
Tags: BlackBerry Developers
Similar Questions
-
[SMS] How to get sms incoming sender number?
As above. I use the API of the PIM Messages, I extracted the incoming sms successfully. How to I take the sender's number? Should I use
MessageContact::npi()
Or
MessageContact::displayableName()
Or
MessageContact::name()
None of them. BTW, NPI is an indicator to a single digit of all the types of numbers that have an address is not of interest to you here.
Take a look at my SmsMessageService application that does what you want. This line especially shows you how to get the number of the sender:
Can also help my KB article:
All the best
Martin
-
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.
-
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.
-
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".
-
Can someone explain to me how capature SMS and MMS messages as they arrive on the Blackberry Storm phone?
Different ways to receive SMS messages:
-
How blackBerry Smartphones: SMS tone change, increase much stronger ringtone,
How can Hi I increase my ringtone?
Change the incoming SMS ring tone?
Also when I open my messages screen, text messages that I received are not there, they are hidden somewhere, how can I see the stratight away like a normal mobile phone?
Can I change my shortcut options?
Is there a calculator in the "BOLD" anywhere that I can add to the context menu
For increasng ringtone.
- Profiles of school boards
- Advanced
- highlight the Active profile
- Click on Menu and select Edit
- SMS text/phone/MMS etc..
- Our host: tone, type of ringtone: change as you wish, Volume: high/medium/low
Follow the steps to change SMS your -.
- Profiles of school boards
- Advanced
- highlight the Active profile
- Click on Menu and select Edit
- SMS text
- Our host: tone, type of ringtone: change as you wish, Volume: high/medium/low
You have a folder named separate SMS and MMS? If this isn't the case, then all the SMS and MMS should land in the Messages folder. If you do not see folder SMS and MMS and SMS are not seen in your messages folder then press Alt and click on Menu and select show all.
What type of shortcut you want to add? Where you want to have shortcuts
-
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
-
Hello
I want to show all sent and received sms and mms with the date and time in my application but I could not find thease details.
Please help me
There is no API that expose this information. You request could listen to incoming SMS messages and build its own database containing this information. It is not possible for the MMS but. You can capture only MMS messages sent to your application.
-
How to receive SMS messages in the application of black berries
Hi all, I hope that you'll be fine. I want to send and receive sms messages from my application. But I want that when sms come so instead of going to the Inbox, it is inside my application. Please tell me how I can do this. Java ME I did it, but now I want to do it in black berries. In Java ME, you set a listener for incoming sms to your main MIDlet class. In black berries in what class I supposed to give listener for incoming sms. Help, please. Thank you.
check the dese nets
-
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
-
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.
-
8703E blackBerry Smartphones has no option to dial SMS or MMS
When entering messages and clicking on, I have no option "Compose SMS", or "MMS", simply compose e-mail, PIN, call, & Instant Message. I contacted Sprint by chat and phone call to technical support (several hours). I've lived a lot of things trying to make it work as it should. If anyone knows how to get this working please help!
Additional information:
OS 4.5 (last)
No service company
Phone has been removed 3 - 4 times (factory reset)
I can send SMS by email, but it's a real pain...
Help, please!
Jeremy
I finally got it to work! Apparently, there was a policy that was blocking SMS. I thougth completely wipe the OS and replace would have taken care of that but I do not. In any case I used method 2 on the next page (method 1 does not work).
blackberryfaq.com/index.php/Remove_IT_Policy
Thanks for your help and I hope this will help others as well with the same problem!
EDIT: Link removed
-
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...
-
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.
Maybe you are looking for
-
Not using laptop Satellite A665 3D 3D when you use WinDVD BD (3D version)
Hello I bought the laptop A665 3d and loaded the Nvidia drivers for the 3D provided with the laptop package. The slide show after you run the wizard 3D grand worked full 3D and 3D of TOSHIBA VIDEO PLAYER worked as well (when you use one of these you
-
View the data in the table on xy graph slowly
Hello I'm simulating a curve stress/strain running on a xy chart. I have a chart 2d data to display a graph xy. When I hit the play button, I got on the first show that nothing on the graph and slowly, you can see the curve move upwards firstly from
-
No puedo playsecure en mi pc dvd
Buenas tardes, ayuda por favor, mi pc no los lee dvd, me da e next message; El Windows Media Player no can produce DVD el porque no hay wont in el equipo any compatible DVD descodificador. Engo TXP, debo hacer?, gracias.
-
Estoy conectándo 2 portatiles is detectan las unidades compartidas y al expandirla para consultar las carpetas of the unidad, saca el message than "no you can get access.
-
The version of Windows7 candidate