Here is the scenario

*Task* : I want to connect a bluetooth device having specific name in my 
application.

*Current Status of my work:*

My device is working as a client in Bluetooth communication.

A. I have registered these broadcast receivers in my application. ACTION_FOUND, 
ACTION_ACL_CONNECTED, ACTION_ACL_DISCONNECT_REQUESTED, 
ACTION_ACL_DISCONNECTED, ACTION_DISCOVERY_FINISHED, 
ACTION_DISCOVERY_STARTED, ACTION_STATE_CHANGED, 
ACTION_SCO_AUDIO_STATE_CHANGED

B. In ACTION_FOUND broadcast I can find that specific device which is 
having SPP or HFP profile if it is currently paired.

I create separate thread and try to create a rfcom connection with UUID 
with this line

s = 
d.createRfcommSocketToServiceRecord(UUID.fromString("00001101-0000-1000-8000-00805F9B34FB"));

s is for socket and d is for device....

C. I am trying to connect it with s.connect();

D. If this connection is established successfully, I will try to read data 
from it

byte[] byt_recv = new byte[6];
int bytes_read = 0;
String recv_str;
int available = s.getInputStream().available();
    if (available >= 0)
        while ((bytes_read = s.getInputStream().read(byt_recv)) != -1) {
            recv_str = new String(byt_recv);

I can not get any flow after this line..... flow directly gets to 
IOException.

[It will sound funny but.] I experimented with reconnecting the device with 
it's power and reconnect it, I see that flow is going from broadcast 
receiving block Of ACL_CONNECTED and VIOLA I can successfully establish 
connection and do anything what I want. 

......... Thus *If i can connect with ACL_CONNECTED I can do it smoothly 
otherwise I can't do anything with it*

I think if I can broadcast ACL_CONNECTED task will be easy so: *how can I 
programmatically broadcast ACL_CONNECTED?*

Or without boradcasting it programmatically can I connect easily??

Thanks

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to