Bluetooth connection in android 2.2
===

I am using android 2.2, i tried the below code for sending the data in android 

    BluetoothDevice device=BluetoothAdapter.getDefaultAdapter().getRemoteDevice(MACID);
    Method m=device.getClass.getMethod("createRFcommSocket",new Class[]{int.class};
    BluetoothSocket socket=(BluetoothSocket)m.invock(device,1);
    socket.connect();
    OutputStream os;
    os=socket.getOutputStream();
    os.write("hai".getBytes());
    os.flush();
    os.close();
    socket.close();

Find the below error :
   

    ERROR : java.io.IOException:Connection refused

Kindly help me in this...