[android-developers] Re: getting exception while connecting to server via bluetooth

2013-01-04 Thread bob
 

Also, be sure you are paired with the server or use createInsecureRfcommSocket 
instead of createRfcommSocket.



On Wednesday, January 2, 2013 11:02:06 PM UTC-6, Ananda Krishna wrote:
>
> hi i have used the reflection method only ..but now i am getting 
> connection variable as false..Kindly tell me what is the mistake that i am 
> doing..
>
> On Wednesday, January 2, 2013 8:14:27 PM UTC+5:30, bob wrote:
>>
>> What does your code for createRfcommSocketToServiceRecord look like?
>>
>>
>> On Wednesday, January 2, 2013 4:58:03 AM UTC-6, Ananda Krishna wrote:
>>>
>>> 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: getting exception while connecting to server via bluetooth

2013-01-04 Thread bob
Well, is your server listening on port one?

Port is to be between 1 and 30, and it may not be one if you specified 
BT_PORT_ANY or a number other than 1 in your server.

This line says it is trying to connect on port one:

btSocket = (BluetoothSocket) m.invoke(device,Integer.valueOf(1));





On Wednesday, January 2, 2013 11:02:06 PM UTC-6, Ananda Krishna wrote:
>
> hi i have used the reflection method only ..but now i am getting 
> connection variable as false..Kindly tell me what is the mistake that i am 
> doing..
>
> On Wednesday, January 2, 2013 8:14:27 PM UTC+5:30, bob wrote:
>>
>> What does your code for createRfcommSocketToServiceRecord look like?
>>
>>
>> On Wednesday, January 2, 2013 4:58:03 AM UTC-6, Ananda Krishna wrote:
>>>
>>> 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: getting exception while connecting to server via bluetooth

2013-01-02 Thread Ananda Krishna
hi i have used the reflection method only ..but now i am getting connection 
variable as false..Kindly tell me what is the mistake that i am doing..

On Wednesday, January 2, 2013 8:14:27 PM UTC+5:30, bob wrote:
>
> What does your code for createRfcommSocketToServiceRecord look like?
>
>
> On Wednesday, January 2, 2013 4:58:03 AM UTC-6, Ananda Krishna wrote:
>>
>> 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: getting exception while connecting to server via bluetooth

2013-01-02 Thread Mariusz Fik
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
> 

Here is official bluetooth guide how to connect as a client: 
http://developer.android.com/guide/topics/connectivity/bluetooth.html#ConnectingAsAClient

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


[android-developers] Re: getting exception while connecting to server via bluetooth

2013-01-02 Thread bob
What does your code for createRfcommSocketToServiceRecord look like?


On Wednesday, January 2, 2013 4:58:03 AM UTC-6, Ananda Krishna wrote:
>
> 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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: getting exception while connecting to server via bluetooth

2013-01-02 Thread Ananda Krishna
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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

[android-developers] Re: getting exception while connecting to server via bluetooth

2012-12-27 Thread bob
 

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 android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en