相关疑难解决方法(0)

列出连接的蓝牙设备?

如何在Android上列出所有连接的蓝牙设备?

谢谢!

android bluetooth

17
推荐指数
1
解决办法
2万
查看次数

以编程方式在Android上启用蓝牙

我正在尝试确定在Android上以编程方式启用蓝牙的首选方式.我发现以下任何一种技术都有效(至少在Android 4.0.4上......):

public class MyActivity extends Activity {
    public static final int MY_BLUETOOTH_ENABLE_REQUEST_ID = 6;
    ...
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ...
        Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
        startActivityForResult(enableBtIntent, MY_BLUETOOTH_ENABLE_REQUEST_ID);
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == MY_BLUETOOTH_ENABLE_REQUEST_ID) {
            if (resultCode == RESULT_OK) {
                // Request granted - bluetooth is turning on...
            }
            if (resultCode == RESULT_CANCELED) {
                // Request denied by user, or an error was encountered while …
Run Code Online (Sandbox Code Playgroud)

android bluetooth

6
推荐指数
2
解决办法
1万
查看次数

标签 统计

android ×2

bluetooth ×2