I registered a service via
BluetoothServerSocket bs = BluetoothAdapter.getDefaultAdapter().listenUsingInsecureRfcommWithServiceRecord("someName" , UUID.fromString(myUuid) );
My question is, is there any programmatic way to determine which channel is being used by this service?
============================ANOTHER SOLUTION========================
:
Thanks for your anserw @Skaard-Solo ,but if I use reflection to create socket then i cannot provide uuid for this.
I made some research and I wrote some simple function that can obtain channel from BluetoothServerSocket.
public int getChannel(BluetoothServerSocket bsSocket){
Field[] f = bsSocket.getClass().getDeclaredFields();
int channel = -1;
for (Field field : f) {
if(field.getName().equals("mChannel")){
field.setAccessible(true);
try {
channel = field.getInt(bsSocket);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
}
field.setAccessible(false);
}
}
return channel;
}