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