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 8431787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:57:00+00:00 2026-06-10T05:57:00+00:00

I can’t figure out how to get my bonded devices on a list through

  • 0

I can’t figure out how to get my bonded devices on a list through this code :

bt_scan.setOnClickListener(new View.OnClickListener() {

        public void onClick(View v) {
            Set<BluetoothDevice> pairedDevices = mBluetoothAdapter.getBondedDevices();
            // If there are paired devices
            if (pairedDevices.size() > 0) {
                // Loop through paired devices
                for (BluetoothDevice device : pairedDevices) {
                    // Add the name and address to an array adapter to show in a ListView
                    mArrayAdapter.add(device.getName() + "\n" + device.getAddress());
                }
            }

                                                        }});}

I don’t know how to get it in a text view or a list view one the same layout or even in another if it’s possible.
I’d like to make a connection to one of the found devices but that’s a whole other story.

(Here is my full code if it helps : http://pastie.org/4582924)

Thanks a lot !

  • 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-10T05:57:01+00:00Added an answer on June 10, 2026 at 5:57 am

    Yes, I agree with Vishwa, the Bluetooth Chat Application is very helpful, I have done same(like yours) kind of development, here is my code,

    main.xml

    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="vertical" android:layout_width="fill_parent"
        android:layout_height="fill_parent">
        <TextView android:id="@+id/title_new_devices"
            android:layout_width="fill_parent" android:layout_height="wrap_content"
            android:background="#666" android:textColor="#fff"
            android:paddingLeft="5dp" />
        <ListView android:id="@+id/new_devices" android:layout_width="fill_parent"
            android:layout_height="wrap_content" />
    </LinearLayout>
    

    Activity Class

    private static BluetoothAdapter mBtAdapter;
    private static ArrayAdapter<String> mNewDevicesArrayAdapter;
    
    private static ArrayList<String> nameList = null;
    private static ArrayList<String> macList = null;
    
    private static ListView newDevicesListView = null;
    
    
    
            // Register for broadcasts when a device is discovered
            IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
            this.registerReceiver(mReceiver, filter);
    
            // Register for broadcasts when discovery has finished
            filter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
            this.registerReceiver(mReceiver, filter);
    
    
            filter = new IntentFilter( BluetoothAdapter.ACTION_DISCOVERY_STARTED );
            this.registerReceiver( mReceiver, filter );
    
            // Get the local Bluetooth adapter
            mBtAdapter = BluetoothAdapter.getDefaultAdapter();
    

    BroadCastReceiver Class

        private final BroadcastReceiver mReceiver = new BroadcastReceiver() 
        {
            @Override
            public void onReceive(Context context, Intent intent) 
            {
                try
                {
                    String action = intent.getAction();
    
                    // When discovery finds a device
                    if ( BluetoothDevice.ACTION_FOUND.equals(action) ) 
                    {
                        // Get the BluetoothDevice object from the Intent
                        BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
    
                        String deviceName = device.getName();
                        String deviceAddress = device.getAddress();
    
                        if ( !nameList.contains( deviceName.trim() + " " + deviceAddress.trim() ) )
                        {
                            nameList.add( deviceName.trim() + " " + deviceAddress.trim() );
                            macList.add( deviceAddress.trim() + "&" + ConstantCodes.TIME + ConstantCodes.EQUALS + DateUtility.getDateTime() );
                        }
    
    //                  System.out.println ( device.getName() );
                        mNewDevicesArrayAdapter.notifyDataSetChanged();
                    } 
                    else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action)) 
                    {
                        mNewDevicesArrayAdapter.notifyDataSetChanged();
                    }
                    else if ( BluetoothAdapter.ACTION_DISCOVERY_STARTED.equals( action ) )
                    {
    //                  nameList.clear();
                    }
                }
                catch ( Exception e )
                {
                    System.out.println ( "Broadcast Error : " + e.toString() );
                }
            }
        };
    

    The code will search for the active bluetooth device and display it in the listView.

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

Sidebar

Related Questions

I'm new to using the Perl treebuilder module for HTML parsing and can't figure
Can someone please explain how this code is working for me? I don't understand
Can I write this with less code, also is .click(function preferred for mobile or
Can any one help me in sorting this out in sed/awk/perl Input file Start
Can find why i get this error can someone help? package Android.data; public class
Can anyone help me trying to find out why this doesn't work. The brushes
Can I change the field public virtual ClassOne ClassOne { get; set; } to
Can any one tell, how to get the result of LINQ query contains group
Can someone thoroughly explain the last line of the following code: def myMethod(self): #
Can anyone explain to me why this program: for(float i = -1; i <

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.