I have tried it and it working fine but now when i use 
btSocket.isConnected() method i am getting false as the rsponse.How should 
i correct it now..

*Code:*
Same as in the earlier post but for these added line

btSocket.connect();
boolean connected =  btSocket.isConnected();
if(true == connected){
}
*
*
*Response:*
connected = false.

On Thursday, December 27, 2012 7:47:12 PM UTC+5:30, bob wrote:
>
> Try it without Reflection.
>
>
>
> On Thursday, December 27, 2012 5:43:16 AM UTC-6, Ananda Krishna wrote:
>>
>> Hi,
>> I am trying to connect to a server in order to receive a file from the 
>> server.. with the help of bluetooth..
>> *The code is as shown below:*
>>
>> private void connectServer() {
>> if(mBluetoothAdapter.isEnabled()){
>>   try{
>>   boolean startDiscovery = mBluetoothAdapter.startDiscovery();
>>   if(true == startDiscovery ){
>> device = 
>> BluetoothAdapter.getDefaultAdapter().getRemoteDevice(SERVER_MAC_ID);
>> Method m = device.getClass().getMethod("createRfcommSocket", new Class[] 
>> { int.class });
>> btSocket = (BluetoothSocket) m.invoke(device,Integer.valueOf(1));
>> mBluetoothAdapter.cancelDiscovery();
>>  btSocket.connect();
>> Toast.makeText(this,"Connected,Waiting to Receive 
>> Files...",Toast.LENGTH_LONG).show();
>>   } 
>>   }catch(Exception ex){
>>   Toast.makeText(this,"Connection 
>> Error:"+ex.getLocalizedMessage(),Toast.LENGTH_LONG).show();
>>   }finally{
>> try {
>> btSocket.close();
>> }catch (IOException e) {
>> Toast.makeText(this,"Connection Error:" + 
>> e.getLocalizedMessage(),Toast.LENGTH_LONG).show();
>> }
>>   }
>> }
>> }
>>
>> I am getting the following exception at the highlighted line..
>> *java.io.IOException: [JSR82] connect: Connection is not created (failed 
>> or aborted).*
>> *
>> *
>> What is the mistake that i am doing...Any help in this regard will be 
>> appreciated.
>> Regards,
>> AnandaKrishna S
>>
>>

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to