J'ai besoin d'obtenir une liste des périphériques Bluetooth disponibles dans la zone en utilisant google android 2.1. Ce n'est pas juste besoin d'une liste de ces appareils, j'ai besoin d'un identifiant unique pour chaque appareil trouvé et j'ai besoin d'un indicateur, comment "bon" le signal est reçu (comme le "niveau" dans android .wifi.ScanResult) ... Comment je fais ça?Comment numériser pour les appareils Bluetooth disponibles dans la gamme Android?
9
A
Répondre
7
35
Découvrez le code ci-dessous:
Lancement de la recherche
mBluetoothAdapter.startDiscovery();
mReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
//Finding devices
if (BluetoothDevice.ACTION_FOUND.equals(action))
{
// Get the BluetoothDevice object from the Intent
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
// Add the name and address to an array adapter to show in a ListView
mArrayAdapter.add(device.getName() + "\n" + device.getAddress());
}
}
};
IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
registerReceiver(mReceiver, filter);
1
méthode d'appel bluetoothScanning, le contexte est nécessaire
void bluetoothScanning(){
IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
context.registerReceiver(mReceiver, filter);
final BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
mBluetoothAdapter.startDiscovery();
}
// Create a BroadcastReceiver for ACTION_FOUND.
private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (BluetoothDevice.ACTION_FOUND.equals(action)) {
// Discovery has found a device. Get the BluetoothDevice
// object and its info from the Intent.
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
String deviceName = device.getName();
String deviceHardwareAddress = device.getAddress(); // MAC address
Log.i("Device Name: " , "device " + deviceName);
Log.i("deviceHardwareAddress " , "hard" + deviceHardwareAddress);
}
}
};
Résultat
Nom: LE Bose Revolve + SoundLink deviceHardwareAddress : MAC 04: 52: C7: D1: B2: 76
.....
Questions connexes
- 1. comment obtenir la notification des appareils dans la gamme bluetooth dans l'objectif c?
- 2. Afficher les appareils avec la gamme de bluetooth windows 7 mobile C#
- 3. obtenir les appareils associés Bluetooth
- 4. Comment connecter quelques appareils Android?
- 5. Comment configurer les autorisations pour Android Bluetooth
- 6. Quels sont les frameworks j2me bluetooth disponibles?
- 7. Profils Bluetooth pour les tablettes
- 8. Explorateur de fichiers pour les appareils Android
- 9. Android: appareils compatibles DLNA
- 10. Quelles sont les classes d'appareils Bluetooth des téléphones Android?
- 11. Est-il possible de numériser pour "id" bluetooth en utilisant l'iphone gamekit api
- 12. Cryptage sur les appareils Android
- 13. Comment numériser les ports COM en C#?
- 14. Application de serveur Bluetooth acceptant les connexions des appareils mobiles
- 15. Android Bluetooth PBAP
- 16. établir une connexion bluetooth entre deux appareils dans l'application j2me
- 17. Android Bluetooth échoue à la paire
- 18. Question sur bluetooth sur Android
- 19. Accéder aux périphériques Bluetooth sur Android?
- 20. Comment utiliser Bluetooth dans l'émulateur Android?
- 21. Compatibilité des appareils Android
- 22. Android Bluetooth Où puis-je obtenir UUID?
- 23. Android bluetooth RFCOMM questions
- 24. Puis-je utiliser jMonkeyEngine pour les appareils Android?
- 25. Comment afficher les branches disponibles dans l'arborescence source Android?
- 26. Silverlight/Moonlight sur les appareils Android
- 27. Activer Désactiver Bluetooth dans Android
- 28. Android - écrire des applications pour les appareils non encore publiés
- 29. android Demande d'appariement Bluetooth
- 30. Compatibilité avec plusieurs écrans pour certains appareils Android dans
quelqu'un a de l'expérience sur cette chose RSSI? je suis un peu précaire ici, puisque cela est défini comme une constante? – xenonite
Votre premier lien - http://developer.android.com/guide/topics/wireless/bluetooth.html#FindingDevices est mort – Dayan
Lien a actuellement cassé – Charlie