Android Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsMobile ProgrammingAndroid Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 28th, 2011, 12:35 AM
SyncMr SyncMr is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2011
Posts: 3 SyncMr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 52 m 36 sec
Reputation 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.

Quote:
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.

Reply With Quote
  #2  
Old October 28th, 2011, 09:36 PM
SyncMr SyncMr is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2011
Posts: 3 SyncMr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 52 m 36 sec
Reputation Power: 0
gentle bounce. any comments or suggestions please

Reply With Quote
Reply

Viewing: Dev Shed ForumsMobile ProgrammingAndroid Development > Discovering available bluetooth devices

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap