Need to programmatically open bluetooth and discover devices in Android

I need to open up bluetooth through my code without asking the user to enable it and then discover all the devices in range and return those devices and then close bluetooth connection.

How to do it?


I suppose here is exactly what you need.

About enabling the Bluetooth without asking the user, here is what the doc says:

Bluetooth should never be enabled without direct user consent. If you want to turn on Bluetooth in order to create a wireless connection, you should use the ACTION_REQUEST_ENABLE Intent, which will raise a dialog that requests user permission to turn on Bluetooth. The enable() method is provided only for applications that include a user interface for changing system settings, such as a "power manager" app.

But if you really want to Enable device bluetooth without asking the user. after add this:

 <uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />

permission to your Manifest use this code in your App


Need Your Help

microsoft PPL library: concurrent_vector push_back data only once

concurrency concurrent-vector

I have a Concurrency::concurrent_vector and want to push_back thread safe a new element only in case it not already exists (that's why I have to perform a search first). How can I accomplish this ?...

Builder throwing “wrong number of arguments” error when passed a block in Ruby 1.9

ruby lambda builder ruby-1.9 argument-error

I'm trying to upgrade a Ruby 1.8 app to 1.9 and hit a bit of a roadblock here. In Ruby 1.8.7, I can pass on a block to Builder 3.0.0 and it gets called as expected:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.