This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
The moose likes Java Micro Edition and the fly likes bluetooth and sms together Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Bookmark "bluetooth and sms together" Watch "bluetooth and sms together" New topic
Author

bluetooth and sms together

mabel foo
Greenhorn

Joined: Oct 07, 2009
Posts: 8
can somebody enlighten me on how to run a bluetooth device search and wait for receiving sms at the same time? i need these 2 to be running simultaneously.. or at least be able to work together effectively.

whenever i run the command "msg = smsconn.receive()" , it will stop here and won't be able to continue to run the bluetooth commands anymore.

hope you guys can guide me along.. thanks!
Srinath Gamage
Ranch Hand

Joined: Jun 19, 2008
Posts: 40

HI,
If you are using con.receive(),use it in a separate thread.Better way is to use MessageListener Interface, as it is non-blocking.
Hope this will help you.
For more info , read MessageListener


SCJP & SCMAD
http://srinathbugz.blogspot.com/
mabel foo
Greenhorn

Joined: Oct 07, 2009
Posts: 8
hey! thanks alot! your info really helped me.

but how do i access the contents of the sms if i use the messagelistener? becos i need to check the content of the sms to set a certain condition.

when i was using con.receive(), i accessed the code this way:

if (smsconn.receive() != null) {

//get contents of sms

}
Srinath Gamage
Ranch Hand

Joined: Jun 19, 2008
Posts: 40

Hi,
As you may have understood by reading above link, when a SMS receives MessageListener invokes notifyIncomingMessage(Conn) method. So in that method notify another thread which you have message reading
code. Use smsconn.receive() there as usual, and you don;t have to check for null, as logic comes to here only if
you are notified by a incoming SMS. Read this article,
it shows real code with threading for MessageListener ( "A Real-Life Example" - Last heading in article ).
mabel foo
Greenhorn

Joined: Oct 07, 2009
Posts: 8
Thanks! I've made use of the reference you gave. (:

Now i have another problem. when i do a bluetooth search for a certain device, the application will send a sms out. i created a new thread to send the sms out. but there is always this exception (java.lang.illegalargumentexception: host format) which i don't know what is causing it. can you help me here?
mabel foo
Greenhorn

Joined: Oct 07, 2009
Posts: 8
hey! i solved the error already. it was actually a careless mistake on my part. (:
Srinath Gamage
Ranch Hand

Joined: Jun 19, 2008
Posts: 40

Good luck
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: bluetooth and sms together
 
Similar Threads
pda/cell phone recommendations
Printer invoking with J2ME application
mms via bluetooth or sms via bluetooth
Code (49) - Application authorization failure"
Bluetooth SMS from PC to cell phone