#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2011
    Posts
    3
    Rep Power
    0

    Question Discovering available bluetooth devices


    Hi,

    I just started learning android development. I am writing an android program to scan available bluetooth devices and list them in a log file and later find the strength of the bluetooth signals.

    Below is a code snippet for Finding available bluetooth devices. As I am new to android, I am unable to figure out what is wrong in the code.

    button2.setOnClickListener(new View.OnClickListener()
    {
    public void onClick(View v)
    {
    ListView lv1 = (ListView) findViewById(R.id.myListView1);
    BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();


    final BroadcastReceiver mReceiver = new BroadcastReceiver()
    {
    public void onReceive(Context context, Intent intent)
    {
    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);
    Log.v("BlueTooth Testing",device.getName() + "\n"
    + device.getAddress());
    }
    }
    };

    String aDiscoverable = BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE;
    startActivityForResult(new Intent(aDiscoverable),DISCOVERY_REQUEST);
    IntentFilter filter = new IntentFilter(BluetoothDevice.ACTION_FOUND);
    registerReceiver(mReceiver, filter);
    mBluetoothAdapter.startDiscovery();
    }
    });
    When I try the debug mode, the control skips the "BroadcastReceiver()". I could not find any entries in the log. Can you help me in figuring out what the problem is and how I can list the available bluetooth devices.
  2. #2
  3. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2011
    Posts
    3
    Rep Power
    0
    gentle bounce. any comments or suggestions please

IMN logo majestic logo threadwatch logo seochat tools logo