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?
Asked
Active
Viewed 9,245 times
2 Answers
9
In case of transferring the files you can make an explicit call to ACTION_SEND using intents as shown below.
You can send a file to a paired device through obex in a couple of ways:
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 . :)

Alex Lockwood
- 83,063
- 39
- 206
- 250

Hussain
- 5,552
- 4
- 40
- 50
-
File sourceFile = new File("//mnt/sdcard/TviderFB.apk"); Intent intent = new Intent(); intent.setAction(Intent.ACTION_SEND); intent.setType("image/jpeg"); intent.putExtra(Intent.EXTRA_STREAM, Uri.fromFile(sourceFile)); ctx.startActivity(intent); – vidit Jul 04 '11 at 12:37
-
i add this code for blue tooth file transfer this code is working fine in my app – vidit Jul 04 '11 at 12:39
-
Hussain i am not able to ask and add my answer in stakoverflow can please help..? – vidit Jul 04 '11 at 12:59
-
Just take a look at it.. U can know y u r not able to ask question or answer it.http://meta.stackexchange.com/questions/86997/what-can-i-do-when-getting-sorry-we-are-no-longer-accepting-questions-from-this/86998#86998 – Hussain Jul 04 '11 at 13:30
4
Follow these steps:
- Read your source file to a byte array (buffer)
Call the write method of your chat service instance passing the bytes to be sent:
// mChatService is your Bluetooth chat service mChatService.write(buffer);
Edit the Handler for
MESSAGE_WRITE
andMESSAGE_READ
cases

Alex Lockwood
- 83,063
- 39
- 206
- 250

sajjad sjj
- 41
- 1
-
hi there, @Mr Bo Persson, and Sajjad sjj . i m voting up your answer, i think this gonna help me out for my requirement, i want to send a object(of myDataType) to the scaned devices, and also read on receiving side, so would you kindly elaborate this techniques, as i have spent less time with android programming so this may seems tough for me, Thanks in Advance.. – Abdul Wahab Aug 05 '11 at 05:36
-
http://stackoverflow.com/questions/6938237/hiding-permission-intent-in-android/6938298#6938298 – Abdul Wahab Aug 08 '11 at 08:25