Samsung Galaxy bluetooth drivers

后端 未结 2 1235
有刺的猬
有刺的猬 2020-12-29 16:55

I have written an application for Android. the main part being that it communicates via bluetooth. I have four devices:
1. Samsung Galaxy S2
2. Samsung Galaxy Gio

2条回答
  •  天命终不由人
    2020-12-29 17:28

    In my app i have bluetooth, working on stock galaxy S (both 1 and 2), Nexus One, HTC Desire, asus tablet and some other device. My app is from android 2.1, and i have this reflaction in my code (with the SDK, it somtimes failed for uknown reason to me, with the "Service discovery failed" error message) that fixed the error:

    BluetoothSocket mSocket = null;
    mBluetoothAdapter.cancelDiscovery();
    
    Method method;
    try {
                method = mBluetoothDevice.getClass().getMethod("createRfcommSocket", new Class[] {int.class});
                mSocket = (BluetoothSocket) method.invoke(mBluetoothDevice,1);
        } catch (NoSuchMethodException e1) {
                e1.printStackTrace();
        } catch (IllegalArgumentException e) {
                e.printStackTrace();
        } catch (IllegalAccessException e) {
                e.printStackTrace();
        } catch (InvocationTargetException e) {
                e.printStackTrace();
        }
    
    mSocket.connect();
    

    but other then that, i use the sdk, and everything works.

提交回复
热议问题