蓝牙文件传输蓝牙、文件传输

2023-09-06 01:55:46 作者:自己选的路跪着也要走完

我开发基于蓝牙聊天示例从 Android开发蓝牙应用网站。我需要做的通过蓝牙文件传输。任何人可以帮助我吗?

I am developing a Bluetooth application based on the Bluetooth Chat Example from the Android Developer Site. I need to do File Transfer via Bluetooth. Can anybody help me out?

推荐答案

在的情况下传输文件,你可以进行显式调用使用意图,以ACTION_SEND如下图所示。

In case of transferring the files you can make an explicit call to ACTION_SEND using intents as shown below.

您可以通过OBEX在几个方面文件发送到配对设备:

You can send a file to a paired device through obex in a couple of ways:

随着 ACTION_SEND 的意图,即会弹出一个菜单,可以处理你要发送的文件类型,从用户需要选择蓝牙的应用,然后该设备

With the ACTION_SEND intent, that will popup a menu with the application that can handle the file type you want to send, from which the user will need to select bluetooth, and then the device.

Intent i = new Intent(Intent.ACTION_SEND); i.setType("image/jpeg");    
i.putExtra(Intent.EXTRA_STREAM, Uri.parse("/sdcard/file.jpg")); 
startActivity(Intent.createChooser(i, "Send Image"));

我认为这将帮助ü。 :)

I think this will help u . :)