aspose file tools*
The moose likes Product and Other Certifications and the fly likes Connector.open() gets stuck?? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Product and Other Certifications
Bookmark "Connector.open() gets stuck??" Watch "Connector.open() gets stuck??" New topic
Author

Connector.open() gets stuck??

chetan dhewal
Ranch Hand

Joined: Nov 07, 2000
Posts: 61
Hi all,

I am trying this code for sending and receiving sms.
The midlet doesnt execute after the call to Connector.open() method.
When executed , after call to open() the emulator ask for "permission" to use message. I click yes/no but the emulator doesnt grant permission and nothing happens. The midlet gets stuck at this alert(permission to use message). I hav given the permission for send& receive in project setting also but avail to no use.

Code...
---------------------------
for receiving:-
msgcon=(MessageConnection) Connector.open("sms://:1234");

for sending:-
msgcon=(MessageConnection) Connector.open("sms://5550000:1234");

---------------------------

the execution of midlets stops on both send/receive open() calls, at the permission alert.

Thnx


Chetan Dhewal<br />SCMAD,SCJP 1.2
avi aro
Greenhorn

Joined: Apr 13, 2006
Posts: 16
Hi,
Do you have network access while using emulator. Please note that while you are behind the proxy, you should make sure that you set the proxy settings in order for emulator to connect to network.
Thanks,
Ransika deSilva
Ranch Hand

Joined: Feb 18, 2003
Posts: 524
Hi,
I think this is due a fundamental rule of IO. Did you open the connection in a different thread. If not the UI gets frozen. Always do the IO in a new thread. Regards.


SCJP 1.4, SCMAD 1.0<br />SCWCD, SCBCD (in progress)
chetan dhewal
Ranch Hand

Joined: Nov 07, 2000
Posts: 61
Hi

The problem was , i dint do the call to open in a different thread, i did it in the commandaction() , the sun emulator was throwing a warning to open the connection in different thread, bt i overlooked it since it was just warning. now i hav come to know that the Sun emulator doesnt let the code go forward if the open()/send()/receive() calls arn't made in seperate thread.

I made 2 different classes for sending and receiving (both implementing Runnable) and put the open+receive and open+send code in their respective run method and guess what the code ran smoothly.

Thnx
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Connector.open() gets stuck??