有什麼方法可以使用Android的內部藍牙將文件發送到其他設備?請舉一個例子。使用android bluetooth發送文件?
7
A
回答
2
這很奇怪的是Android有沒有明確的OBEX API兩種權限。使用OBEX
用於文件共享或者您可以使用this解決方案
BluetoothDevice device;
String filePath = Environment.getExternalStorageDirectory().toString() + "/file.jpg";
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);
(它需要this class -
- Android OBEX:無論如何,看看這個項目)
4
這是一個小功能,您可以使用
/**
* Method to share data via bluetooth
* */
public void bluetoothFunctionality() {
String path = Environment.getExternalStorageDirectory() + "/"
+ Config.FILENAME;
File file = new File(path);
Intent intent = new Intent();
intent.setAction(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(file));
startActivity(intent);
}
此方法將文件發送到使用默認設備藍牙功能的其他裝置。 在你做這個之前,你必須首先配對這個設備,這是有限制的。 發送不同類型的文件,你必須只改變MIME類型集合類型的方法
在清單文件必須添加像
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH" />
+3
如果我沒有錯,那些權限不是必需的。 – xmen
相關問題
- 1. 在Android中使用WebSocket發送文件
- 2. android bluetooth obd2應用程序開發
- 3. 發送文件android
- 4. 使用Android Bluetooth Bluetooth獲取當前值示例應用程序
- 5. 使用Android發送推文
- 6. 使用Android發送推文
- 7. 將數據發送至Core Bluetooth Framework Xcode
- 8. Android 1.6上使用backport-android-bluetooth
- 9. 從android bluetooth發送傳感器數據到arduino的問題
- 10. 發送數據從android bluetooth到藍色電腦
- 11. bluetooth android錯誤
- 12. ADB over Bluetooth Android
- 13. 使用TClientDataSets發送文件
- 14. 使用Javascript發送文件
- 15. 使用ajax發送文件
- 16. 使用Pyserial發送文件?
- 17. 使用Httpwebrequest發送文件
- 18. 發送APK文件android
- 19. Android藍牙文件發送
- 20. bluetooth with android and raspberrypi
- 21. bluetooth android force關閉
- 22. Android - 用MMS發送音頻文件
- 23. 更改文件權限:/system/etc/bluetooth/audio.config
- 24. Android:使用ACTION_SEND發送HTML文本Intent
- 25. 無法在android中使用電子郵件發送.csv文件
- 26. 使用Android intent發送HTML郵件
- 27. 使用Android Intent.ACTION_SEND發送電子郵件
- 28. 的Android發送郵件使用SMTP
- 29. 無法使用Bluetooth HC-06發送數據 - 應用程序停止工作
- 30. Android發送xml文件不發送附件
你爲什麼不先google? – Pratik