I want to get the remote device's address,its name,its UUID , accept the BluetoothServerSocket of an already paired bluetooth device
<p>I am creating a bluetooth remote which remotely accesses a media player on a computer . I have sent an intent to the default Bluetooth system settings . Now what I want is to get the device's name, its MAC address, its UUID. Also I want to accept the BluetoothServerSocket assigning it to a BluetoothSocket. Here is my code .</p>

<pre><code>BluetoothSocket mskt=null;
BluetoothServerSocket msskt= null;
BluetoothAdapter mbtha= BluetoothAdapter.getDefaultAdapter();
OutputStream mmOutStream;
BluetoothDevice mdev=null;

BluetoothAdapter mbtha= BluetoothAdapter.getDefaultAdapter();
    if(mbtha.isEnabled()==false){
        Toast.makeText(this, "Bluetooth is Disabled",Toast.LENGTH_LONG).show();
        Intent settingsIntent = new Intent(android.provider.Settings.ACTION_BLUETOOTH_SETTINGS);
        startActivity(settingsIntent);
        Set&lt;BluetoothDevice&gt; pairedDevices = mbtha.getBondedDevices();

        }
    else if(mbtha.isEnabled()==true){
        Toast.makeText(this, "Bluetooth is already enabled",Toast.LENGTH_LONG).show();
    }
    String adrs= mbtha.getAddress();
    mdev = mbtha.getRemoteDevice(adrs);
    String mname = mdev.getName();
    String uuid = new String(mdev.getUuids().toString());
    try {
        msskt=mbtha.listenUsingRfcommWithServiceRecord(mname, UUID.fromString(uuid));
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    try {
        mskt=msskt.accept();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    try {
        mmOutStream = mskt.getOutputStream();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
</code></pre>

<p>Is the code correct. If not then what can I do to get the already connected / paired device
now since I have let the default system settings to do the work of pairing??</p>
