简体   繁体   中英

Connection bluetooth SPP on android

Sorry friends to bother you. I am stay at home mom and new in Android development which I took us as part time job. I have expereince in Java development.

I have tried to look that bluetooth chat example and searched here a lot about from where to start. The bluetooth chat sample never shows up the list of paired devices when I tried to run on my mobile. Whereas here in lot of questions there is thing UUID is used. I am not able to find out from where my friends retreived it.

My question is can someone guide me just few lines from where to start, I have a SPP device paired/unpaired (Idont know its UUID) I wish to connect it through my mobile. Just few lines of assistance is requested as time of you people is very precious, I understand it is my stupid question.

Thanks.

i use bluetooth spp in my app and get my data binary, so i can drop you some lines of code i use.

private BluetoothSocket sock;
private InputStream in;
private BluetoothDevice zee;

    /*
     * ****PAIR DONGLE****
     */

    zee = BluetoothAdapter.getDefaultAdapter().getRemoteDevice("YO:UR:MA:CA:DR:ES:S");

    m = zee.getClass().getMethod("createRfcommSocket",
            new Class[] { int.class });
    sock = (BluetoothSocket) m.invoke(zee, Integer.valueOf(1));
    sock.connect();
    int temp = 0;
    in = sock.getInputStream();

    try {
        while (true) {
            temp = in.read();
            //do what you like with your byte stored in temp
    } catch (IOException e) {}

hope that helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM