2

I am building an application using apache cordova, and I already can check if the bluetooth is available using the BluetoothSerial plugin.

If it is not then I redirect to a page where I have a button to call the device settings dialogue, but I cannot find any example of how to do this. Is it even possible?

I have found examples of getting the wifi / gps settings, but not the settings page itself.

Artjom B.
  • 61,146
  • 24
  • 125
  • 222
jmiguel77
  • 824
  • 9
  • 19

1 Answers1

1

As far as I know you will need native code to call the bluetooth settings.

I'm assuming you know how to call java method from javascript. call this code

final Intent intent = new Intent(Intent.ACTION_MAIN, null);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
final ComponentName cn = new ComponentName("com.android.settings", 
              "com.android.settings.bluetoothSettings");
intent.setComponent(cn);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity( intent);

This should open the bluetooth settings. See this for more details.

Community
  • 1
  • 1
AtanuCSE
  • 8,832
  • 14
  • 74
  • 112