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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:38:58+00:00 2026-05-23T09:38:58+00:00

Does anybody know of any example available that illustrates Bluetooth development on Android. I

  • 0

Does anybody know of any example available that illustrates Bluetooth development on Android.

I have read the tutorial here and I understand everything on that page.

However when it comes to implementing the Bluetooth code, into an application it is necessary to view the Bluetooth Chat example to understand how it all works.

Bluetooth Chat example here

This example is good, but it is also hard to comprehend because each device is initially set up to be a server.

Who is the server and do both devices send out server sockets until one device scans?

Once a device makes itself discoverable does it become the server?

When does the OnResume activity start, because once that starts and the mChatService has been initialized in SetupChat, the device will start an Accept thread.

Some code examples are given below, and link to the full Bluetooth chat is available above.

@Override
public synchronized void onResume() {
    super.onResume();
    if(D) Log.e(TAG, "+ ON RESUME +");

    // Performing this check in onResume() covers the case in which BT was
    // not enabled during onStart(), so we were paused to enable it...
    // onResume() will be called when ACTION_REQUEST_ENABLE activity returns.
    if (mChatService != null) {
        // Only if the state is STATE_NONE, do we know that we haven't started already
        if (mChatService.getState() == BluetoothChatService.STATE_NONE) {
          // Start the Bluetooth chat services
          mChatService.start();
        }
    }
}

private void setupChat() {

    // Initialize the BluetoothChatService to perform bluetooth connections
    mChatService = new BluetoothChatService(this, mHandler);

    // Initialize the buffer for outgoing messages
    mOutStringBuffer = new StringBuffer("");
}


/**
 * Start the chat service. Specifically start AcceptThread to begin a
 * session in listening (server) mode. Called by the Activity onResume() */
public synchronized void start() {
    if (D) Log.d(TAG, "start");

    // Cancel any thread attempting to make a connection
    if (mConnectThread != null) {mConnectThread.cancel(); mConnectThread = null;}

    // Cancel any thread currently running a connection
    if (mConnectedThread != null) {mConnectedThread.cancel(); mConnectedThread = null;}

    setState(STATE_LISTEN);

    // Start the thread to listen on a BluetoothServerSocket
    if (mSecureAcceptThread == null) {
        mSecureAcceptThread = new AcceptThread(true);
        mSecureAcceptThread.start();
    }
    if (mInsecureAcceptThread == null) {
        mInsecureAcceptThread = new AcceptThread(false);
        mInsecureAcceptThread.start();
    }
}

What I am asking for is for any examples of Bluetooth, that are easier to understand and examples that clearly segregate the server side and the client side of Bluetooth.
I have Google’d this, and I have read all details available on the developer.android.com website.

  • 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-23T09:38:59+00:00Added an answer on May 23, 2026 at 9:38 am

    From what I have gathered, the distinction: server and client exists only while the Bluetooth connection is being established (ie during the discovery and pairing process). For the connection to be established, one device acts as a server (using an instance of BluetoothServerSocket class) and the other acts as a client (using an instance of the BluetoothSocket class). The (acting) server listens for incoming requests and the client requests listening servers to connect. After the connection is established (see the details of the methods used on the Android Dev Guide), both the (initially called) server and client interact using the BluetoothSocket object only. So no such server/client distinction exists.

    You can check out the code of the Bluetooth Chat example on the Dev Guide, particularly of the BluetoothChatService class. Call to the method createRfcommSocketToServiceRecord() returns a BluetotohSocket to the listening(server) device. The requesting device(client) as it is uses a similar object.

    True, further example codes would be nicer.

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

Sidebar

Related Questions

does anybody know any resources that I can refer to?
Does anybody know if there is any library of managed wrappers that allows me
Does anybody know, how to make chart like this? I have not found any
Does anybody know of a good solid plugin that allows a user to have
Does anybody have any working example of RSA encryption with OpenSSL.NET ? I want
Does anybody know or have any documents which I can use to build a
Does anybody know how I can find the closest element that is for example
Does anybody have any idea why iPad zoom (you know, where you use two
Does anybody know any good resources for learning how to program CIL with in-depth
Does anybody know any fine open source cube browser? Ideally, it would be something

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.