问题描述
我使用的Apache Cordova构建应用程序,并且我已经可以检查蓝牙可使用。
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?
我已经得到WIFI / GPS设置发现的例子,而不是设置页面本身。
I have found examples of getting the wifi / gps settings, but not the settings page itself.
推荐答案
据我所知,您将需要本地code调用蓝牙设置。
As far as I know you will need native code to call the bluetooth settings.
我假设你知道如何从JavaScript调用Java方法。称之为code
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了解更多详情。
This should open the bluetooth settings. See this for more details.
这篇关于我怎样才能在设备使用科尔多瓦打开设置页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!