Unable to send files through bluetooth component

Hi Ramesh

I’m sure in your mind you know what you want to do - but we really really do not :upside_down_face: That’s because detail matters and you have given a specification that is too vague.

Is this a school project? It’s not unusual for a teacher to set a project without understanding the consequences.

Yes Chris , its a school project. They want me to create an app through which I can send images and documents using bluetooth component only.
I didnt see any method in bluetooth component to send files.I was wondering how to implement it.It would be helpful if I can get some idea on how to do it.

OK - Google designed Android to take care of file exchanges between devices. This makes sense if you think about it - what if you had ten Apps on your Android device? All ten would have to be able to send files if the OS didn’t do it. The analogy in the PC World would be the humble printer. You might have 10 programs that need to print on paper, but you don’t have a printer for each individual program.

So, with Android, Users create files with their Apps, then they use their device to send (share) those files, managed by Android and sent by any means available, including bluetooth, that is compatible with the receiving device. That’s the normal.

Therefore, if you are to design an App that does it’s own sending via Bluetooth, it is imperative to know what it is sending to, because all devices and computers and OSs are different and there are different versions of Bluetooth too, with the collection of differences ranging from minor to major. It’s especially difficult to send a file without needing to provide software for the receiving end too.

“It’s especially difficult to send a file without needing to provide software for the receiving end too.” - For this I thought of creating another app for the receiving end. Thus two apps Sender app and receiver app.

So does this mean the device receiving the file is also Android based?

@Taifun has this example for a chat between two Android Bluetooth:
https://puravidaapps.com/btchat.php

I did this tutorial in Spanish a long time ago to send a text file from one Android to another, a mobile is Server and other Client.
http://kio4.com/appinventor/9D_bluetooth_enviar_archivo.htm

1 Like

yes it will be an Android device.

Hi Juan,
we have methods to send text in bluetooth, I’m trying to convert image and document to text and then send it to other device.

@ChrisWard , @Juan_Antonio ,@TIMAI2 - This is the requirement that I got, to be implemented :

  1. Develop a Bluetooth based document and image file transfer app like AirDrop.
  2. Develop a Bluetooth base document file and image transfer app enabled with encryption.

With the source and target devices being android, you should have everything you need?

AS we dont have methods to send files in bluetooth component ,I thought of converting the files using KIO4_File2String ,KIO4_Base641 but these components are returning “File not found” when I pass the Result.uri of activityStarter.

Both devices must have an app made with App Inventor and Bluetooth?

Its upto me how I develop it. They didn’t specify it, until I am able to send the file from one device to other.Whether I use one app or two apps its upto me.

But did you try what I suggested: converting the content uri to a file path and ensuring the result was suitable for input to the base64 block ? (see above)

I tried doing it but not sure if I did it correct or not. I passed the Result.Uri for filename.
image

Try first convert a small image file (~ 2KB) in the assets to String.
FileToString
fileName = //myimage.png

GotString
string

Use this version:
http://kio4.com/appinventor/277_extension_imagen_string.htm

okay Juan. Ill try and get back to you.

Hi Juan, It worked if I did it with a file from assets.I was able to see the converted string of the jpg file.

Firstly, sorry I pointed you at the wrong block! It should be this one:

component_method

Secondly, using GET_CONTENT does not return a good file path in the same way that using PICK does for images. You may need to build your own file picker using the File extension.

1 Like

Send that String by Bluetooth to other device, then this device convert string to image file.

For now, test code snippets as separate mini projects to prove feasibility.

After that, design the GUIs of Send and Receive Apps on paper, with a list of requirements. Do not try to reinvent the world!

If you decide that one of the Apps needs more than one screen, use Virtual Screens. Screen1 is the ‘real’ Screen and device-sized Vertical Arrangements on it are displayed/hidden as required - they are your Virtual screens.

Backup your work to your PC frequently

https://www.professorcad.co.uk/appinventortips#TipsGui GUI Layout
https://www.professorcad.co.uk/appinventortips#TipsImages Images
https://www.professorcad.co.uk/appinventortips#TipsApk Cannot Build/Install/Run APK
https://www.professorcad.co.uk/appinventortips#TipsBluetooth Bluetooth

You can raise a new Forum Topic if you get stuck with some detail or other, but it’s your homework and up to you to do the thinking now :grin: If you do raise a Topic, make sure it is well defined from the start!