How can I open the settings page in the device using cordova

徘徊边缘 提交于 2019-12-11 07:51:53

问题


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.


回答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.



来源:https://stackoverflow.com/questions/27785674/how-can-i-open-the-settings-page-in-the-device-using-cordova

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!