2015-01-05 38 views
1

我正在使用apache cordova構建應用程序,並且我已經可以使用the BluetoothSerial plugin來檢查藍牙是否可用。如何使用cordova打開設備中的設置頁面

如果不是那麼我重定向到一個頁面,我有一個按鈕來調用設備設置對話框,但我找不到如何做到這一點的任何示例。它甚至有可能嗎?

我找到了獲取wifi/gps設置的例子,但沒有找到設置頁面本身。

回答

1

據我所知,您將需要本機代碼來調用藍牙設置。

我假設你知道如何從javascript調用java方法。撥打此號碼

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

相關問題