Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7753395
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T12:03:13+00:00 2026-06-01T12:03:13+00:00

I have with an blue tooth application from android api sample.I am displaying blue

  • 0

I have with an blue tooth application from android api sample.I am displaying blue tooth paired device in a list when the user selects a device try for send a message to selected paired device then that message should deliver to that device.From the a this specification i would like to develop as when user checks the paired device then type a message in edit field then click on send button.when user click on send button then the user can connect to selected device then send that message to that device then if delivery is success immediately close the connection.
I have implemented code as follows

 ListView listDevicesFound;
 ArrayAdapter<String> btArrayAdapter;
 @Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    // Set up the window layout
    requestWindowFeature(Window.FEATURE_CUSTOM_TITLE);
    setContentView(R.layout.main);
    btArrayAdapter = new ArrayAdapter<String>(BluetoothChat.this, android.R.layout.simple_list_item_multiple_choice);
    listDevicesFound.setAdapter(btArrayAdapter);
    listDevicesFound.setChoiceMode(ListView.CHOICE_MODE_MULTIPLE);
    listDevicesFound.setSelected(true);
    listDevicesFound.setClickable(true);
    Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
      if (pairedDevices.size() > 0) {
          for (BluetoothDevice device : pairedDevices) {
           String deviceBTName = device.getName();
           String deviceBTAddress = device.getAddress();
           btArrayAdapter.add(deviceBTName + "\n"  + deviceBTAddress);
          }
      }

      mSendButton.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {


          SparseBooleanArray checked = listDevicesFound.getCheckedItemPositions();
            Set<BluetoothDevice> devices = btAdapter.getBondedDevices();
            Log.v("prasad", "devices.size()===>>>"+devices.size());
            for (int j=0;j<=devices.size();j++) 
               {
                    System.out.println(j);
                    if(checked.get(j))
                    {
                        String devadd= listDevicesFound.getItemAtPosition(j).toString();
                        String devaddress=devadd.substring(0,devadd.length()-17);
                        Log.v("prasad", "address===>>>"+devaddress);


                        /*
                         *BluetoothDevice:
                         *Represents a remote Bluetooth device. 
                         *A BluetoothDevice lets you create a connection with the respective device 
                         *or query information about it, such as the name, address, class, 
                         *and bonding state 
                         */

                        for(BluetoothDevice itDevices:devices)
                        {
                            Log.v("prasad", "itDevices.getAddress()===>>>"+itDevices.getAddress());
                            if(devadd.endsWith(itDevices.getAddress()))
                            {



                                            Log.v("1111","Here the adderess of selected device :"+itDevices.getAddress());


             }
         }
      }
   }




         //Please help on following steps
         //1.How to connect to a selected device code here                

         String message = messageEdit.getText().toString();
         //2.How to send the message to selected device here

         //3.How to close the connection with selected device here



            }
    });


  }  

please follow my comments in coding lines

please any body help me….

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T12:03:14+00:00Added an answer on June 1, 2026 at 12:03 pm

    Have you looked at the Bluetooth Chat sample app? I think that is very close to what you are trying to do:
    http://developer.android.com/resources/samples/BluetoothChat/index.html

    Also, the Android Bluetooth Developer’s Guide has code samples related to the specific questions you asked:

    //1.How to connect to a selected device code here
    http://developer.android.com/guide/topics/wireless/bluetooth.html#ConnectingDevices
    Tells you how to call accept() on a BluetoothServerSocket to listen for incoming on one side, and then call connect() on a BluetoothSocket on the other side.

    //2.How to send the message to selected device here
    http://developer.android.com/guide/topics/wireless/bluetooth.html#ManagingAConnection
    Explains about attaching your socket to I/O streams and then calling read/write on the streams.

    //3.How to close the connection with selected device here
    You just call close() on your BluetoothSockets. Typically you do this from one thread, which causes the pending operation in your Bluetooth thread to throw an I/O Exception.

    But again, I would recommend reading through the Chat sample and the Developer Guide, as listed above.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple Android native java application that reads data from a Bluetooth
I have a couple questions about submitting blue-tooth enabled apps on the iPhone. I
i have a program that receives data from a wireless device over bluetooth...i now
hey in my application i have to give user an option called BLUETOOTH Is
I have an application that processes data from bluetooth and send it to the
I have an application that uses the bluetooth to receive some data (bytes) from
My customer is developing a bluetooth device. I am developing an android application which
I have a VS2010 project which is a windows application that acquires data from
So I have my Android Bluetooth application that has it's host and clients. The
I am working with the Android Bluetooth Chat sample application. I am trying to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.