如何在不使用UIID和套接字的情况下通过蓝牙在Android中传输数据?

时间:2015-02-03 19:20:16

标签: android android-bluetooth

大家好我想通过蓝牙从一台设备向另一台设备发送一些数据,但问题是第二台设备没有安装此应用程序所以我不知道uiid所以我不能使用套接字所以如何通过使用秒发送设备os蓝牙服务。 提前谢谢。

1 个答案:

答案 0 :(得分:1)

你可以试试这个方法

public void sendFileToDevice(BluetoothDevice device,String path){
        File file = new File(path);

        Intent intent = new Intent();
        intent.setAction(Intent.ACTION_SEND);
        intent.setClassName("com.android.bluetooth", "com.android.bluetooth.opp.BluetoothOppLauncherActivity");
        intent.setType("text/plain");
        intent.putExtra(BluetoothDevice.EXTRA_DEVICE, device);
        intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
        startActivity(intent);
    }