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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:24:10+00:00 2026-06-11T13:24:10+00:00

In my project i have to read barcodes using barcode scanner Symbol CS3070 through

  • 0

In my project i have to read barcodes using barcode scanner Symbol CS3070 through bluetooth. i.e; i have to establish a connection between android device and barcode scanner through bluetooth. Can any one tell me how to read values from barcode reader and how to setup for communication? I’ve already read the Bluetooth Developer Guide, and I don’t want to use Barcode Reader in Bluetooth Keyboard Emulation (HID) mode (I’ve some textview that can be filled using soft keyboard and Barcode Reader and I can’t control the focus)

I’d use a thread like this to communicate with a reader

    private class BarcodeReaderThread extends Thread {
    private final BluetoothServerSocket mmServerSocket;

    public BarcodeReaderThread(UUID UUID_BLUETOOTH) {
        // Use a temporary object that is later assigned to mmServerSocket,
        // because mmServerSocket is final
        BluetoothServerSocket tmp = null;
        try {
            // MY_UUID is the app's UUID string, also used by the client code
            tmp = mBluetoothAdapter.listenUsingRfcommWithServiceRecord("BarcodeScannerForSGST", UUID_BLUETOOTH);
            /*
             * The UUID is also included in the SDP entry and will be the basis for the connection
             * agreement with the client device. That is, when the client attempts to connect with this device,
             * it will carry a UUID that uniquely identifies the service with which it wants to connect.
             * These UUIDs must match in order for the connection to be accepted (in the next step)
             */
        } catch (IOException e) { }
        mmServerSocket = tmp;
    }

    public void run() {
        BluetoothSocket socket = null;
        // Keep listening until exception occurs or a socket is returned
        while (true) {
            try {
                socket = mmServerSocket.accept();
                try {
                    // If a connection was accepted
                    if (socket != null) {
                        // Do work to manage the connection (in a separate thread)
                        InputStream mmInStream = null;

                        // Get the input and output streams, using temp objects because
                        // member streams are final
                        mmInStream = socket.getInputStream();

                        byte[] buffer = new byte[1024];  // buffer store for the stream
                        int bytes; // bytes returned from read()

                        // Keep listening to the InputStream until an exception occurs
                        // Read from the InputStream
                        bytes = mmInStream.read(buffer);
                        if (bytes > 0) {
                            // Send the obtained bytes to the UI activity
                            String readMessage = new String(buffer, 0, bytes);
                            //doMainUIOp(BARCODE_READ, readMessage);
                            if (readMessage.length() > 0 && !etMlfb.isEnabled()) //Se sono nella parte di picking
                                new ServerWorker().execute(new Object[] {LEGGI_SPED, readMessage});
                        }
                        socket.close();
                    }
                }
                catch (Exception ex) { } 
            } catch (IOException e) {
                break;
            }
        }
    }

    /** 
     * Will cancel the listening socket, and cause the thread to finish
     */
    public void cancel() {
        try {
            mmServerSocket.close();
        } catch (IOException e) { }
    }
}

Thanks

  • 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-11T13:24:11+00:00Added an answer on June 11, 2026 at 1:24 pm

    I just received my device and when I paired and connected the device it automatically sends the data to the currently focused EditText. What version of Android are you using because I tried it on ICS and JB and it worked this way.
    I have not tested it in any earlier versions.

    Edit:

    I downgraded my phone to Gingerbread and found out it does not work the same way but I have a solution:

    This is important! >> First you must scan the barcode in the manual that says “Serial Port Profile (SPP)”.

    btAdapter = BluetoothAdapter.getDefaultAdapter();
    if (btAdapter.isEnabled())
    {
        new BluetoothConnect().execute("");
    }
    
    public class BluetoothConnect extends AsyncTask<String, String, Void>
    {
        public static String MY_UUID = "00001101-0000-1000-8000-00805F9B34FB";
    
        @Override
        protected Void doInBackground(String... params)
        {
            String address = DB.GetOption("bluetoothAddress");
            BluetoothDevice device = btAdapter.getRemoteDevice(address);
            try
            {
                socket = device.createRfcommSocketToServiceRecord(UUID.fromString(MY_UUID));
                btAdapter.cancelDiscovery();
                socket.connect();
                InputStream stream = socket.getInputStream();
                int read = 0;
                byte[] buffer = new byte[128];
                do
                {
                    try
                    {
                        read = stream.read(buffer);
                        String data = new String(buffer, 0, read);
                        publishProgress(data);
                    }
                    catch(Exception ex)
                    {
                        read = -1;
                    }
                }
                while (read > 0);
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return null;
        }
    
        @Override
        protected void onProgressUpdate(String... values)
        {
            if (values[0].equals("\r"))
            {
                addToList(input.getText().toString());
                pickupInput.setText("");
            }
            else input.setText(values[0]);
            super.onProgressUpdate(values);
        }
    }
    

    This is an incomplete version of my working code but you should get the gist.
    I hope this solution works for you as well!

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

Sidebar

Related Questions

I'm using Linq to SQL on a project and have read articles about how
Hey I'm Having this problem in android project! I have read so many topics
I'm using xCode 4.3.2. In this project, i have read the xml data and
I have a VS project with an IntermediateDirectory like this: ....\temp\$(SolutionName)\$(ProjectName). I can read
Ok, so read my question before you respond. I have a c# project that
I have project asp.net with namespace test and I'm using resources (files Resource.resx and
I have project on rails 3 with multiplayer using Faye. The error block in
I have a project in Visual 2005 generated using CMake, and everytime I press
I want to install sfJQueryReloadedPlugin in my project. I have read on the official
I want to start a my first Java EE project. I have read a

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.