小编Ric*_*ick的帖子

如何使用Android蓝牙设备选择器检索蓝牙设备信息?

这是我正在使用的测试代码:

public class IOConnectDirect extends Activity {

private static final String TAG = "IOConnectDirect";

private static final int REQCODE_BLUETOOTH_RESULT = 0;

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.i(TAG, "onCreate");
    setTitle(getTitle() + "--" + TAG);
    Intent intentBluetooth = new Intent();
    intentBluetooth.setAction("android.bluetooth.devicepicker.action.LAUNCH");
    //android.bluetooth.devicepicker.action.DEVICE_SELECTED not working .
    startActivityForResult(intentBluetooth, REQCODE_BLUETOOTH_RESULT);
}


@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    Log.i(TAG, "onActivityResult(" + requestCode  +"," + resultCode + ")");

    switch (requestCode) {
    case REQCODE_BLUETOOTH_RESULT:
        Log.i(TAG, "requestCode = REQCODE_BLUETOOTH_RESULT");

        if(resultCode == RESULT_OK) { …
Run Code Online (Sandbox Code Playgroud)

android bluetooth

5
推荐指数
1
解决办法
8432
查看次数

标签 统计

android ×1

bluetooth ×1