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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:21:43+00:00 2026-05-22T19:21:43+00:00

I have a problem detecting zero class bluetooth devices with my Galaxy Tab using

  • 0

I have a problem detecting zero class bluetooth devices with my Galaxy Tab using the Android Bluetooth API. It simply does not “see” some devices although I can detect them with my phone or computer. Has anyone run into this problem? I´m writing an app which depends on pairing with a device through bluetooth and some help in this regard would be most appreciated.

  • 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-22T19:21:44+00:00Added an answer on May 22, 2026 at 7:21 pm

    Note: This solution will only work with old Android OSs, due to it’s need for access to the device logs.

    Yes! I have exactly the same problem, abeit on a Samsung Galaxy S, and LG Optimus One. I wrote a class you can reuse to fix this, no idea if it will work on the Galaxy Tab, but you can try:

    package com.yourpackagename;
    
    import java.io.BufferedReader;
    import java.io.IOException;
    import java.io.InputStreamReader;
    import java.text.ParseException;
    import java.text.SimpleDateFormat;
    import java.util.ArrayList;
    import java.util.Calendar;
    import java.util.Date;
    import java.util.UUID;
    import java.util.regex.Matcher;
    import java.util.regex.Pattern;
    
    import android.app.Activity;
    import android.app.ProgressDialog;
    import android.bluetooth.BluetoothAdapter;
    import android.bluetooth.BluetoothDevice;
    import android.bluetooth.BluetoothSocket;
    import android.content.BroadcastReceiver;
    import android.content.Context;
    import android.content.Intent;
    import android.content.IntentFilter;
    import android.os.AsyncTask;
    
    // This class exists due to a bug in the Broadcomm bluetooth stack, which is
    // used by many Android smart-phone manufacturers (LG, Samsung HTC etc.).  That
    // bug prevents discovery of ALL bluetooth devices that report their Class of Device (CoD)
    // code as 0x00, which prevent many SPP (Serial Port Profile) devices from working.
    // 
    // See: http://www.google.com/codesearch/p?hl=en#4hzE-Xyu5Wo/vendor/brcm/adaptation/dtun/dtunc_bz4/dtun_hcid.c&q=%22Device%20[%25s]%20class%20is%200x00%20-%20skip%20it.%22&sa=N&cd=1&ct=rc
    // And: http://stackoverflow.com/questions/4215398/bluetooth-device-not-discoverable
    // And: http://www.reddit.com/r/Android/comments/hao6p/my_experience_with_htc_support_eu_anyone_has/
    //
    // How to use (from your Activity class):
    // 
    //  (new BluetoothClassZeroDiscoveryTask(this, new BluetoothDiscoveryCallback())).execute();
    //
    // Where BluetoothDiscoveryCallback is a class defined e.g. in your Activity.  The call method
    // will be called after the discovery task completes, and is passed the complete list
    // of paired bluetooth devices, including those that are undiscoverable due to the above bug.
    //
    //  private class BluetoothDiscoveryCallback implements Action<ArrayList<BluetoothDevice>>
    //  {
    //      public void call(ArrayList<BluetoothDevice> devices)
    //      {
    //          // Now you have the list of ALL available devices, 
    //          // including those that report class 0x00.
    //      }
    //  }
    //
    //  // Java equivalent of the built-in Action from C#.
    //  public interface Action<T>
    //  {
    //      void call(T target);
    //  }
    //
    public class BluetoothClassZeroDiscoveryTask extends AsyncTask<Void, Void, Void>
    {
        // This is the well-known ID for bluetooth serial port profile (SPP) devices.
        public static final UUID BluetoothSerialUuid = UUID.fromString("00001101-0000-1000-8000-00805F9B34FB");
    
        private Activity _parent;
        private boolean _discoveryComplete = false;
        private Action<ArrayList<BluetoothDevice>> _callback;
        private ArrayList<BluetoothDevice> _devices = new ArrayList<BluetoothDevice>();
        private Calendar _discoveryStartTime;
        private SimpleDateFormat _logDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss.SSS");
        private BluetoothAdapter _adapter;
        private ProgressDialog _progressDialog;
    
        public BluetoothClassZeroDiscoveryTask(Activity parent, Action<ArrayList<BluetoothDevice>> callback)
        {
            _callback = callback;
            _parent = parent;
            _adapter = BluetoothAdapter.getDefaultAdapter();
    
            IntentFilter foundFilter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
            _parent.registerReceiver(mReceiver, foundFilter);
            IntentFilter finishedFilter = new IntentFilter(BluetoothAdapter.ACTION_DISCOVERY_FINISHED);
            _parent.registerReceiver(mReceiver, finishedFilter);
    
            // This task performs a scan for bluetooth devices, which 
            // takes ~ 12 seconds, so show an indeterminate progress bar.
            _progressDialog = ProgressDialog.show(_parent, "", "Discovering bluetooth devices...", true);
        }
    
        // Kicks off bluetooth discovery.
        @Override
        protected Void doInBackground(Void... params)
        {
            _discoveryStartTime = Calendar.getInstance();
            _adapter.startDiscovery();
    
            while (!_discoveryComplete)
            {
                try
                {
                    Thread.sleep(500);
                }
                catch (InterruptedException e) { }
            }
    
            _adapter.cancelDiscovery();
            return null;
        }
    
        // Provide notification of results to client.
        @Override
        protected void onPostExecute(Void result)
        {
            _progressDialog.dismiss();
            _parent.unregisterReceiver(mReceiver);
            _callback.call(_devices);
        }
    
        // Handler for bluetooth discovery events.
        private final BroadcastReceiver mReceiver = new BroadcastReceiver()
        {
            @Override
            public void onReceive(Context context, Intent intent)
            {
                String action = intent.getAction();
                if (BluetoothDevice.ACTION_FOUND.equals(action))
                {
                    BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
    
                    // If it's already paired, skip it, (we'll add it after the scan completes).
                    if (device.getBondState() != BluetoothDevice.BOND_BONDED)
                    {
                        _devices.add(device);
                    }
                }
                else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.equals(action))
                {
                    // Add all already-paired devices to the list.
                    for (BluetoothDevice device : _adapter.getBondedDevices())
                    {
                        _devices.add(device);
                    }
    
                    // Trawl through the logs to find any devices that were skipped >:(
                    try
                    {
                        Process process = Runtime.getRuntime().exec("logcat -d -v time *:E");
                        BufferedReader bufferedReader = new BufferedReader(
                                new InputStreamReader(process.getInputStream()));
    
                        String line;
                        Pattern pattern = Pattern.compile("(.{18}).*\\[(.+)\\] class is 0x00 - skip it.");
                        while ((line = bufferedReader.readLine()) != null)
                        {
                            Matcher matcher = pattern.matcher(line);
                            if (matcher.find())
                            {
                                // Found a blocked device, check if it was newly discovered.
                                // Android log timestamps don't contain the year!?
                                String logTimeStamp = Integer.toString(_discoveryStartTime.get(Calendar.YEAR)) + "-" + matcher.group(1);
                                Date logTime = null;
                                try
                                {
                                    logTime = _logDateFormat.parse(logTimeStamp);
                                }
                                catch (ParseException e) { }
    
                                if (logTime != null)
                                {
                                    if (logTime.after(_discoveryStartTime.getTime()))
                                    {
                                        // Device was discovered during this scan,
                                        // now we want to get the name of the device.
                                        String deviceAddress = matcher.group(2);
                                        BluetoothDevice device = _adapter.getRemoteDevice(deviceAddress);
    
                                        // In order to get the name, we must attempt to connect to the device.
                                        // This will attempt to pair with the device, and will ask the user
                                        // for a PIN code if one is required.
                                        try
                                        {
                                            BluetoothSocket socket = device.createRfcommSocketToServiceRecord(BluetoothSerialUuid);
                                            socket.connect();
                                            socket.close();
                                            _devices.add(device);
                                        }
                                        catch (IOException e) { }
                                    }
                                }
                            }
                        }
                    }
                    catch (IOException e) {}
    
                    _discoveryComplete = true;
                }
            }
        };
    }
    

    See also:
    http://zornsoftware.codenature.info/blog/pairing-spp-bluetooth-devices-with-android-phones.html

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

Sidebar

Related Questions

I have problem creating new instance of excel 2007 using VBA (from Access 2002).
I have problem designing pseudo-code for these problems. It is not an assignment problem.
I have problem in some JavaScript that I am writing where the Switch statement
I have problem with return statment >.< I want to store all magazine names
I have problem with starting processes in impersonated context in ASP.NET 2.0. I am
I have problem compilin this code..can anyone tell whats wrong with the syntax CREATE
I have problem with ActionLink. I'd like to pass to my ActionLink parameter for
I have problem when I try insert some data to Informix TEXT column via
I have problem with fancybox. I want to write a function that will run
i have problem with autorotate on iphone i set up in all classes -

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.