Hello everyone I want to send some data via bluetooth from one device to another device but tthe problem is that second device dont have this application installed so i dont know the uiid so i can not use sockets so how to send via using second device os bluetooth service. Thanks in advance.
Asked
Active
Viewed 375 times
0
-
What do you want to send?A file or something else? – Feb 03 '15 at 19:27
-
i want to send text and files.. – android_learner Feb 03 '15 at 19:27
-
Please refer this http://stackoverflow.com/questions/8178809/send-file-using-android-bluetooth – Feb 03 '15 at 19:29
-
Mr Goutam sorry to say but mu code not recognize BluetoothShare? – android_learner Feb 03 '15 at 19:34
-
I did not get what do you mean – Feb 03 '15 at 19:45
-
Sir I mean the link you have provide is having Bluetoothshare in their code when i use this code Bluetoothshare is not get recognized in my code so tell me what is Bluetoothshare here? – android_learner Feb 03 '15 at 19:50
-
Please go through second answer – Feb 03 '15 at 19:55
-
I have paired my device with my customized code i want code which will fit in my code? – android_learner Feb 03 '15 at 20:03
1 Answers
1
You can try this method
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);
}
-
can u please tell that how i will perform using socket in remote device using their base bluetooth uiid – android_learner Feb 03 '15 at 20:59
-
For that there is a good documentation in android developers website.http://developer.android.com/guide/topics/connectivity/bluetooth.html – Feb 03 '15 at 21:03
-
But they have not tell how i get the base bluetooth uiid of remote device? – android_learner Feb 03 '15 at 21:05
-
UUID is not something like you get from the device,You just use generate uuid from online generators like this https://www.uuidgenerator.net/ and use in both the devices – Feb 03 '15 at 21:08
-
sir but the problem is that if i have to use the socket approach then i sholud have the uiid of remote device bluetooth as i have not installed my app on both devices so it is not possible to use mu own uiid so i have to use the system bluetooth uiid – android_learner Feb 03 '15 at 21:12
-
While using socket approach the one device works as server and other works as client. So the only way i know is installing apllication on both the sides.and I hope the what you system uuid may be some random uuid – Feb 03 '15 at 21:16
-
But the thing is that if i use your suggested solution then i think it only work for small data transfer for large files it not work? – android_learner Feb 03 '15 at 21:18
-
-
around 10 mb and even your code not working for small files even for text. – android_learner Feb 03 '15 at 21:33
-
-
i am not getting any error but text transfering not start... i am sending text – android_learner Feb 03 '15 at 21:36
-
Please have a look at this solution http://stackoverflow.com/questions/4921384/how-to-send-file-using-bluetooth-on-android-programatically it may be useful – Feb 04 '15 at 18:37