Skip to content
This repository has been archived by the owner on Jan 27, 2021. It is now read-only.

AcceptThread crash #21

Open
ryazmin opened this issue Apr 23, 2015 · 13 comments
Open

AcceptThread crash #21

ryazmin opened this issue Apr 23, 2015 · 13 comments

Comments

@ryazmin
Copy link

ryazmin commented Apr 23, 2015

AcceptThread will crash if listenUsingRfcommWithServiceRecord method throws exception.
In this case mmServerSocket will be null,
and crash will be at AcceptThread.run line socket = mmServerSocket.accept();

Also need to check for null in AcceptThread .cancel method or catch any exception.

@akexorcist
Copy link
Owner

Thanks!

@xiaomochn
Copy link

in class app.akexorcist.bluetotohspp.library.BluetoothSPP line 371 when arr_name.size()==0 a arr ArrayIndexOutOfBoundsException occured

@vicctor
Copy link

vicctor commented Oct 10, 2015

I noticed this same problem in case if I will switch off the BT in my phone during connection.

@eraare
Copy link

eraare commented Nov 23, 2015

I set the Listener, but received nothing. Follow is the codes:
bt.setOnDataReceivedListener(new BluetoothSPP.OnDataReceivedListener() {
@OverRide
public void onDataReceived(byte[] data, String message) {
System.out.println("APP:received-" /+ message/);
}
});
Need your help, thanks

@waro163
Copy link

waro163 commented Mar 19, 2016

i have the same problem as r00kie0, setting the bluetooth data listener, but i can not receive
anything, i need your help. thanks.

@ali4fun
Copy link

ali4fun commented Sep 9, 2016

onDataReceived(byte[] data, String message)
NOT working here.. same problem.. plz give solution

@jaime1990
Copy link

The function of onDataReceived not work, plz give solution. tks~

@matheuslf
Copy link

Hello Guys,

To receive messages correctly the text should have a 0x0A and 0x0D at the end. Like you can see in this code:

// Keep listening to the InputStream while connected
            while (true) {
                try {
                    int data = mmInStream.read();
                    if(data == 0x0A) {

                    } else if(data == 0x0D) {
                        buffer = new byte[arr_byte.size()];
                        for(int i = 0 ; i < arr_byte.size() ; i++) {
                            buffer[i] = arr_byte.get(i).byteValue();
                        }
                        // Send the obtained bytes to the UI Activity
                        mHandler.obtainMessage(BluetoothState.MESSAGE_READ
                                , buffer.length, -1, buffer).sendToTarget();
                        arr_byte = new ArrayList<Integer>();
                    } else {
                        arr_byte.add(data);
                    }
                } catch (IOException e) {
                    connectionLost();
                    // Start the service over to restart listening mode
                    BluetoothService.this.start(BluetoothService.this.isAndroid);
                    break;
                }
            }

@jtoros13
Copy link

What about that "AcceptThread" null reference mentioned in the very first message?
Do you plan to fix it?
This causes great inconvenience to our company, so if you have stalled the project, plz let me know to use another package

@stkq
Copy link

stkq commented Oct 5, 2017

jtoros13 did you find a solution? I'm getting the same problem and I don't have access to the phone in question.

@jtoros13
Copy link

jtoros13 commented Oct 5, 2017

Nope, no "out of the box" solution found.
I downloaded the code in my project as a different package, and after adding it as external reference, I changed the code itself.

Hope this helps
jtoros13

@garispe
Copy link

garispe commented May 6, 2018

@akexorcist
First of all, thank you for your work in this project.

Sorry for my english, I'm from Argentina. As mentioned in some comments, I need to know if it is going to solve the "AcceptThread" bug, because I have a project to finish and one of the things that slow me down is this bug.

@aq62386238
Copy link

sorry i got this problem how to slove
"Unsupported method: BaseConfig.getApplicationIdSuffix().
The version of Gradle you connect to does not support that method.
To resolve the problem you can change/upgrade the target version of Gradle you connect to.
Alternatively, you can ignore this exception and read other information from the model."

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests