Bonjour j'essaie d'envoyer des données via bluetooth et mon probleme est que j'ai un java.IOException connection refused
voici comment je construis mon socket
ANdroid Manifest
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32 BluetoothDevice remoteDevice = mBluetoothAdapter.getRemoteDevice(currentAddress); System.out.println("remote device" + remoteDevice ); BluetoothSocket tmp = null; BluetoothSocket mmSocket = null; Method m = null; try { tmp = remoteDevice.createRfcommSocketToServiceRecord(MY_UUID_SECURE); try { m = remoteDevice.getClass().getMethod("createRfcommSocket", new Class[] {int.class}); } catch (NoSuchMethodException e) { // TODO Auto-generated catch block e.printStackTrace(); } tmp = (BluetoothSocket) m.invoke(remoteDevice, 1); } catch (IOException e) { System.out.println(e.getMessage()); } catch (IllegalAccessException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IllegalArgumentException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (InvocationTargetException e) { // TODO Auto-generated catch block e.printStackTrace(); } mmSocket = tmp;
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7 <uses-permission android:name="android.permission.BLUETOOTH" /> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" /> <uses-permission android:name="android.permission.ACCESS_BLUETOOTH_SHARE" android:protectionLevel="signature" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Avez vous une idée sur ce qui peu causé cet exception ? aurai-je oublier une permission ?
Merci pour tout conseil !
Partager