Jump to content
JohnLM

Is it possible to send text from android to a windows laptop and back over wifi?

Recommended Posts

specs: window 7 64bit, delphi 11.2, phone s10+ with android 12 

 

I've been wanting to ask this question for some time and an opportunity came to me and I'm now asking...

 

I would like to send text from my galaxy s10+ phone to my laptop over wifi, and back, from my laptop to Android over wifi.  I want to type some text, a word, or a whole paragraph, and send it. 

 

Are there any demos or how-tos for this?

 

I searched my sample folders but did not find anything.  Also, I do not want to use a USB cable, nor do I want to join/use any outside services from other sources.  I don't want to download any apps, register, and all that.  I want this to be strictly private and only from my two devices. TIA 

Share this post


Link to post

How about app tehtering? Ready to use components, multi-platform, ip/bluetooth app to app communication

https://docwiki.embarcadero.com/RADStudio/Alexandria/en/Using_App_Tethering

Share this post


Link to post

Have you considered using TCP/UDP sockets?  Indy ships with Delphi and runs on both Windows and Android.

  • Like 1

Share this post


Link to post

@Zoran Bonuš - I've been looking into the app tethering idea and found this video (below) but I've read some comments and some people say it no longer works.  But I will take a look into it later today and see since the project is in my C:\Users\Public\Documents\Embarcadero\Studio\22.0\Samples folder, the project is dated 8/23/2022 so there must be some updates made since. 

 

 

@Remy Lebeau - I searched around for TCP/UDP demo(s) on tethering or sending/receiving data (text/image/etc) but did not find any source code snippets to get me started.  I am not fluent in Indy as I'd like to be. 

 

Thank you both for your suggestions.  

 

PS: forgot to mention at the beginning, I am using the Delphi Professional, both XE7 and 11.2 versions, mainly using version 11.2

Edited by JohnLM

Share this post


Link to post

Progress Update. . .

 

Well, I tried the sample from the above video from the C:\Users\Public\Documents\Embarcadero\Studio\22.0\Samples\Object Pascal\RTL\Tethering\BDShoppingList folder and it fails to connect on the mobile device. The VCL app is up and running, and the TetherDBClient compiles and runs on the mobile device, but there is no database showing and the two devices do not connect, that is, when I click on the [Connect] button on the mobile device. The screen on the mobile device is blank or white with the message "You are not connected" displayed at the bottom left. 

Share this post


Link to post
29 minutes ago, JohnLM said:

The VCL app is up and running, and the TetherDBClient compiles and runs on the mobile device, but there is no database showing and the two devices do not connect, that is, when I click on the [Connect] button on the mobile device

Same here. Not sure which method(s) it tries to use to tether in this case - I can take a deeper look later if no-one else answers beforehand. 

Share this post


Link to post

I've been debugging various things. I found that there are two passwords in each app, but Unit 1 seems to reference two, as shown below.
 

Unit 2 - VCL app    - 'TetherBDTest'       - but makes no reference to it in the source code, nor does it check/verify it.
Unit 1 - Mobile app - 'TetherBDTestClient' - this has a reference in the source code and has 'TetherBDTest' in it. 

I've compiled various password scenarios to no avail and still does not connect. 

Edited by JohnLM

Share this post


Link to post

I'm still debugging this connection problem.  I tried setting the [Allowed Adapters] to 'Bluetooth' in both apps (VCL/Mobile) but it still will not connect. In this case, I get a black screen on the cellphone. 

 

I've been watching the video (posted link in the previous post above) many times and still do not understand why it will not connect.  I believe that the person in that video did not cover enough of the process for App Tethering.  I also believe he left out a number of steps in the source code. 

Share this post


Link to post

Perhaps check the AppTethering here : https://github.com/DeveloppeurPascal/Des-solutions-de-synchronisations-de-donnees

 

You also can embed a web server in your desktop app and use GET/POST http commands.

 

And if you want to do something really free, use a TSocket and a TSocketStream to send and receive texts. This unit will help to write/read a string over a stream : https://github.com/DeveloppeurPascal/librairies/blob/master/Olf.RTL.Streams.pas

Share this post


Link to post
Guest

Concerning the use ot TSocket I hate it when I see this when closing the app, raising an error on a proper shutdown.  Compiled and ran it as is written.

 

image.png.4764831c52192fcc296239b8cbe3a2b5.png

Share this post


Link to post
44 minutes ago, TazKy said:

Concerning the use ot TSocket I hate it when I see this when closing the app, raising an error on a proper shutdown.  Compiled and ran it as is written.

 

image.png.4764831c52192fcc296239b8cbe3a2b5.png

I'm agree, cleaning sockets instances have to be done when they disconnect. I have to add it to my sample program and in other tools, but no real impact for a little program with little volume of users. For a big server it has to be fixed.

Share this post


Link to post
Guest

When the "raise" occurs deep in the code that is outside of your code that really is a bummer.

Share this post


Link to post

Update on this endeavor. . .

 

So far, I have not been able to get App Tethering working on my laptop and Android phone via Delphi 11.2 Alexandria.  This has been a big failure!

 

And just to note,  I've been working on multiple smaller projects having similar purposes/features. 

Share this post


Link to post
26 minutes ago, JohnLM said:

Update on this endeavor. . .

 

So far, I have not been able to get App Tethering working on my laptop and Android phone via Delphi 11.2 Alexandria.  This has been a big failure!

 

And just to note,  I've been working on multiple smaller projects having similar purposes/features. 

Did you check you firewall or antivirus on both side ?

 

If you have Bluetooth enable, you can try AppTethering with Bluetooth instead of ethernet, I never tried it but perhaps it could solve your problem ?

https://docwiki.embarcadero.com/RADStudio/Alexandria/en/Using_App_Tethering

Share this post


Link to post

Post Deleted - I got confused and posted a reply for another similar topic.  I will update this one later. 

 

Edited by JohnLM

Share this post


Link to post

@Patrick PREMARTIN.  It depends. I was running a small test app (from a code snippet found elsewhere here on this forum in another discussion) and that app was showing me an IP 10.0.0.3 most of the time.  And running on my cellphone, it was showing and IP 127.0.0.1

Share this post


Link to post

Could you try this sample project ?

 

The server listen on port 8080 for all IP by default on the PC. The firewall should ask if you want to open the port on public or private network (private should be the one clicked by default if your computer has the good parameters).

 

You can specify an IP address in the client project and compile it for Windows and for Android.

 

Check the IP with "ipconfig" or in the network parameters in a terminal window.

 

(just download a ZIP of the repository to compile this sample : no need of any dependance
https://github.com/DeveloppeurPascal/Socket-Messaging-Library 
or you can use Git, of course)

Edited by Patrick PREMARTIN

Share this post


Link to post

Patrick, I was busy trying another idea using one of the Embarcadero samples (the Photowall) from the Rad Studio Delphi XE7 Pro IDE and samples folder, and it worked. I was able to take a photo from my phone and send it over to a VCL app in Windows on my laptop.  Only this time, I had the wifi turned on in my phone. When I turned it off, the app did not work. Now, I want to try the same app but from the Delphi 11.2 IDE and its sample folder version (not the XE7's one). 

Share this post


Link to post

Patrick, when I attempt to compile (under Delphi 11.2) the Photowall app for mobile, it fails to complete -- see below.

 

Do you know how I can resolve this new conflict?  I think it has to do with XE7 and D11.2 is not compatible or something all the sudden. I've never had this issue before when writing mobile apps in both XE7 and D11.2 on the same day. 

 

163961542_08072023mon0510pmcompilingtomobilewillnotwork.thumb.png.93d64f3f9b54b0484bfa00fe6dd5e292.png

 

 

Share this post


Link to post

I started a new mobile app, threw a button and edit box, and compiled it to Android successfully and it ran. 

 

So it appears to be an issue with the XE7 vs D11.2 when compiling the D11.2 version of the Photowall sample app in D11.2

 

If anyone know's have to resolve the issue mentioned in my previous post above with the photo showing the error, please advise how I can fix and compile it in D11.2, TIA 

Share this post


Link to post
8 hours ago, JohnLM said:

Patrick, when I attempt to compile (under Delphi 11.2) the Photowall app for mobile, it fails to complete -- see below.

 

Do you know how I can resolve this new conflict?  I think it has to do with XE7 and D11.2 is not compatible or something all the sudden. I've never had this issue before when writing mobile apps in both XE7 and D11.2 on the same day. 

 

163961542_08072023mon0510pmcompilingtomobilewillnotwork.thumb.png.93d64f3f9b54b0484bfa00fe6dd5e292.png

 

 

It's a normal security feature on Android : we can't replace an existing app when it's from an other source than previous one. The compiler add a key in the program, if you compile with an other you have to remove the app on your phone before.

Share this post


Link to post
9 hours ago, JohnLM said:

Patrick, I was busy trying another idea using one of the Embarcadero samples (the Photowall) from the Rad Studio Delphi XE7 Pro IDE and samples folder, and it worked. I was able to take a photo from my phone and send it over to a VCL app in Windows on my laptop.  Only this time, I had the wifi turned on in my phone. When I turned it off, the app did not work. Now, I want to try the same app but from the Delphi 11.2 IDE and its sample folder version (not the XE7's one). 

About the WIFI, it's normal : AppTethering uses a broadcast UDP message to find other programs on the local network. It don't work over the Internet (so not over 3G/4G/5G/... except if you give a public address with a routing to your computer).

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×