【问题标题】:How to transfer data through bluetooth in android without using UIID and sockets?如何在不使用 UIID 和套接字的情况下通过 android 中的蓝牙传输数据?
【发布时间】:2015-04-03 03:02:44
【问题描述】:

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

【问题讨论】:

  • 您要发送什么?文件还是其他内容?
  • 我想发送文本和文件..
  • Goutam 先生很抱歉,但是 mu 代码无法识别 BluetoothShare?
  • 我没明白你的意思

标签: android android-bluetooth


【解决方案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);
    }

【讨论】:

  • 你能告诉我将如何使用他们的基本蓝牙uiid在远程设备中使用套接字
  • 为此在android开发者网站上有一个很好的文档。developer.android.com/guide/topics/connectivity/bluetooth.html
  • 但他们还没有告诉我如何获得远程设备的基本蓝牙 uiid?
  • UUID 不是你从设备上得到的,你只需使用像这样uuidgenerator.net 这样的在线生成器生成 uuid 并在两个设备中使用
  • 先生,但问题是,如果我必须使用套接字方法,那么我应该拥有远程设备蓝牙的 uiid,因为我没有在两个设备上安装我的应用程序,所以不可能使用 mu自己的uiid所以我必须使用系统蓝牙uiid
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2013-09-23
  • 2013-04-27
  • 1970-01-01
  • 2023-04-07
  • 2011-03-31
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多