0

I would like to beable to automatically turn on discoverability on an android device without the user being prompted with a security dialog.

I'm developing two applications, one for an Android TV box, one for my smartphone. I want to be able to control the android TV box using my smartphone, however I want to do this without needing to turn on discoverability manually on the TV box as that would require a remote of some kind completely defeating the point of the application.

Is there another way to enable discoverability through API which I could use - preferably via a service.

thanks,

Nathan.

  • This would only work if I could tell the server which device to connect to - which I can't. Wifi direct is too new to use , so now looking around for an opensource Bluetooth library for android. – Nathaniel Bennett Dec 31 '12 at 10:53

2 Answers2

2

Wow, 4 years go. As an answer to my younger self I would think that what you were trying to do is not possible as you said so yourself, it's a matter of security (You yourself reference a "sercuity dialog").

If an app could turn on Bluetooth whenever it wished and had full covert access to the entire Bluetooth hardware, then the app could potentially with malicious intent damage parts of the Android OS and delete or worse; distribute the User's personal information.

What you would be looking at instead is implementing the system that computer peripheral manufactures implement with wireless keyboard and mice, that is to extract the Bluetooth connectivity to a separate hardware layer (A usb dongle) and via USB implement a human interface device, thus in turn filtering the Bluetooth connection to allow only the sending of HID input information to the device.

To myself 4 years ago,

Nathan.

-1

A bit late, but you need to do this with an intent, from the documentation on Android Bluetooth:

Intent discoverableIntent = new
Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
discoverableIntent.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 300);
startActivity(discoverableIntent);

http://developer.android.com/guide/topics/connectivity/bluetooth.html#EnablingDiscoverability

Jonno_FTW
  • 8,601
  • 7
  • 58
  • 90