Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/207.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android蓝牙推送文件_Android_Bluetooth - Fatal编程技术网

Android蓝牙推送文件

Android蓝牙推送文件,android,bluetooth,Android,Bluetooth,我想通过蓝牙将文件发送到其他设备。 我想以编程方式将文件发送到设备。有人知道怎么做吗 我可以通过蓝牙OPP发送文件吗 您可以尝试以下内容: 步骤1在AndroidManifest.xml中添加蓝牙权限 <uses-permission android:name="android.permission.BLUETOOTH"/> <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/> 步骤

我想通过蓝牙将文件发送到其他设备。 我想以编程方式将文件发送到设备。有人知道怎么做吗
我可以通过蓝牙OPP发送文件吗

您可以尝试以下内容:

  • 步骤1在AndroidManifest.xml中添加蓝牙权限

    <uses-permission android:name="android.permission.BLUETOOTH"/>
    <uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
    
  • 步骤3您可以从链接下载

完成了

BluetoothDevice device; String filePath = Environment.getExternalStorageDirectory().toString() + "/data.txt";  
ContentValues values = new ContentValues(); 
values.put(BluetoothShare.URI, Uri.fromFile(new File(filePath)).toString()); 
values.put(BluetoothShare.DESTINATION, device.getAddress()); 
values.put(BluetoothShare.DIRECTION, BluetoothShare.DIRECTION_OUTBOUND); 
Long ts = System.currentTimeMillis(); values.put(BluetoothShare.TIMESTAMP, ts); 
Uri contentUri = getContentResolver().insert(BluetoothShare.CONTENT_URI, values);