2013-09-24 2 views

답변

0

현재이 코드를 테스트 할 수는 없지만 블루투스의 이름과 기타 매개 변수를 얻는 방법에 대한 아이디어를 줄 수는 있습니다.

static BluetoothSocket socket ; 
public static boolean btCon(Context ctx){ 

Method m; 
try { 
     BluetoothDevice devc = BluetoothAdapter.getDefaultAdapter().getRemoteDevice(MAC_ADRS); 

     m = devc.getClass().getMethod("createRfcommSocket", new Class[]{int.class}); 
     socket = (BluetoothSocket)m.invoke(devc, Integer.valueOf(1)); 
    socket.connect(); 

    String name = devc.getName();/* or */ String name2 = devc.getName().toString(); 
     Log.i("Test","Name: "+name); 
     Log.i("Test","Name 2: "+name2); 

    return true; 
}catch(Exception e) 
{ 
    return false; 
} 
} 
1

당신은 모든 원격 장치 :

private void discoveryDevice(){ 
// Register the BroadcastReceiver 
IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND); 

    registerReceiver(mReceiver, filter); // Don't forget to unregister during onDestroy 

    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(); 
     // When discovery finds a device 
     if (BluetoothDevice.ACTION_FOUND.equals(action)) { 
      // Get the BluetoothDevice object from the Intent 
      BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); 

      Log.d(TAG, "device " + device.getName() + "\n" + device.getAddress()); 
     } 
    } 
}; 

원격 장치의 이름을 취득하는 것은 정말 좋은를 얻기 위해 다음과 같은 코드를 사용할 수 있습니다 축복하는 코드 :

Log.d(TAG, "device " + device.getName() + "\n" + device.getAddress()); 
관련 문제