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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:00:33+00:00 2026-05-26T21:00:33+00:00

I have a bluetooth device with SPP profile and bluetooth version 2.1. I have

  • 0

I have a bluetooth device with SPP profile and bluetooth version 2.1.
I have an app which connects to that device and communicates with it. The device uses “Just Works” pairing technique.

I am facing a problem on certain phones like Samsung Galaxy tablet, Galaxy S.

The problem is after the user exits from the app, I am closing the sockets and disconnecting from the device. After successful disconnection, it is observed that the device’s entry is removed from the paired devices list.

  • 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-05-26T21:00:34+00:00Added an answer on May 26, 2026 at 9:00 pm

    I haven’t worked with tablets, but I did write an app that used SPP for Android phones. What I found was that in order to get Bluetooth to be stable, I have to manually bond with the device I want to communicate with. We used the code below to initiated bonding from within the app, and it should preserve the bonding just as if you manually paired through the settings menu.

    Here is the general flow:
    1) Register a BroadcastReceiver to listen for BluetoothDevice.ACTION_BOND_STATE_CHANGED
    2) After device discovery you should have a BluetoothDevice object.
    3) Use reflection to call ‘createBond’ method on a BluetoothDeviceObject
    3a) Wait for bond state change events before opening sockets

    BluetoothDevice device = {obtained from device discovery};
    Method m = device.getClass().getMethod("createBond", (Class[])null);
    m.invoke(device, (Object[])null);
    
    int bondState = device.getBondState();
    if (bondState == BluetoothDevice.BOND_NONE || bondState == BluetoothDevice.BOND_BONDING)
    {
        waitingForBonding = true; // Class variable used later in the broadcast receiver
    
        // Also...I have the whole bluetooth session running on a thread.  This was a key point for me.  If the bond state is not BOND_BONDED, I wait here.  Then see the snippets below
        synchronized(this)
        {
            wait();
        }
    }
    

    4) Wait for the bond state to change from BOND_BONDING to BOND_BONDED

    Inside a BroadcastReciever:

    public void onReceive(Context context, Intent intent)
    {
        if (BluetoothDevice.ACTION_BOND_STATE_CHANGED.equals(intent.getAction()))
        {
            int prevBondState = intent.getIntExtra(BluetoothDevice.EXTRA_PREVIOUS_BOND_STATE, -1);
            int bondState = intent.getIntExtra(BluetoothDevice.EXTRA_BOND_STATE, -1);
    
            if (waitingForBonding)
            {
                if (prevBondState == BluetoothDevice.BOND_BONDING)
                {
                    // check for both BONDED and NONE here because in some error cases the bonding fails and we need to fail gracefully.
                    if (bondState == BluetoothDevice.BOND_BONDED || bondState == BluetoothDevice.BOND_NONE)
                    {
                        // safely notify your thread to continue
                    }
                }
            }
        }
    }
    

    5) Open sockets and communicate

    You can also you the ‘removeBond’ method via reflection to remove your device from the pairing list.

    Hope this helps!

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

Sidebar

Related Questions

I have an app that uses bluetooth SPP (RFCOMM) to communicate with a piece
I have a simple Bluetooth app on android that connects to a device using
In my app, which uses a proprietary bluetooth device, I'm working on self-correcting some
I'm working on app, which uses GPS data. I have an external bluetooth GPS
I'm currently working on an app that connects to a bluetooth device and receives
i have a program that receives data from a wireless device over bluetooth...i now
I have written a small app that puts my bluetooth in discoverable mode for
I am developing an application which uses Bluetooth to connect to a device and
I have a Bluetooth device and I do not remember the pairing code (aka
I'm making an app which constantly receives Heart Rate from a bluetooth device in

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.