What is the library I should use in my apps to make it send a file between two phones

akgh2010

Member
Licensed User
Longtime User
I'm new here in B4A. But originally I'm a VB.Net or VC# Developer along with SQL Server or Oracle, what I mean by that I know how to build an Algorithm for any application. I want to make an app. that can send a file between two phones that have Android OS, and at the same time installed with the same app. that I want to build. It's like using the feature "send file" with Skype. My question is: what is the library I should use with B4A IDE and if there is a simple example or a thread I'll be really thankful guys.
 
Last edited:

akgh2010

Member
Licensed User
Longtime User
Thanks Erel for your reply in short notice. But I was thinking not on a local LAN, but rather on Internet, like Skype or TeamViewer that uses Internet connection to send the file between two devices have the same apps.
I mean how can we know the IP address of the other device to send him a file that uses Internet connection, to accept it later.I saw one of my friends that has i-phone 4G that has an apps with the same idea that you add someone who already on your contacts in a group of your own name in that apps, lets say "Friends" group and whenever you want to send to that group a text message or a photo or a file you can send it to that group and it will reach all the contacts that are being stored in that group at once. But my friend told me that the same apps must be installed on all the other i-phones devices for that group.
Even the apps has a feature to tell you that someone of that group is online, means that he opens the apps in his i-phone and using it.
This is the main idea Erel, I hope I could explain what I need.
Is this possible to do it with B4A, or should I resort to eclips with Java and XML. It's really difficult comparing to B4A and I don't understand most of it.
I found B4A like a miracle to me to build apps for Androids.
And if your answer to be yes, it's possible, what is the main idea to do it, and what is the library to use it?
I'm sorry for asking too many questions but I need to do the apps for my Prof. supervising me with a course in my school.
 
Last edited:
Upvote 0

rbsoft

Active Member
Licensed User
Longtime User
As Erel said you would need to use the network library.

You need to create a server application and a Android client application. The client app connects to the server. The server thenb holds the client's information (Name, IP adress, status, etc.). Once you have this information your client can communicate either directly with another client or via the server.

Skype and Teamviewer work like this. That's why Teamviewer can connect behind firewalls. Teamviewer connections are always outgoing connections, you connect via the server, never directly to the other client.
 
Upvote 0

hackhack

Active Member
Licensed User
Longtime User
It is not possible to connect two devices over the Internet because of security issues. It doesn't matter if you are writing the app with B4A or Eclipse.

So how does the FTP apps work? You transfer from one device to another over the internet?
 
Upvote 0

akgh2010

Member
Licensed User
Longtime User
Thanks guys for your sharing...
Erel... I know that I should use a third party web server but I was skeptical if I can connect two devices together without that third party.
for instance, Skype, yahoo and Win. live msgr use the user account to tell the other contacts that a specified user is online or not.
TeamViewer uses the same principle but in a different technique, the application will give the client a unique ID within the server and a PW for one session only, and that's cool also.
And subscribing with a third party web server for one time to finish my project for my Prof. is just wast of money and efforts if it's not for investment online.
So, guys, what about the great IDEA that hackhack comes up with...
do you think that I can use it to send a file with it, whether that file is a doc, text msg (it can be composed and saved then send as a notepad file), PDFs, ZIP, RAR and any file of any type?
I think this is a great idea presented by hackhack...
but there is one question:
using FTP, can I send a packet telling other contacts in a specific group that a new contact was offline and then becomes online again... or vice versa?
I will begin to study FTP library... but really guys I need your advice.. and I appreciate your effort... all.
 
Upvote 0

akgh2010

Member
Licensed User
Longtime User
As Erel said you would need to use the network library.

Skype and Teamviewer work like this. That's why Teamviewer can connect behind firewalls. Teamviewer connections are always outgoing connections, you connect via the server, never directly to the other client.


I can assure you that Teamviewr can work both way, outgoing and incoming connections... you can use it to send Voice over IP between the two computers and even use web cam.. I always use it to fix software issues remotely while chit chatting at the same time with the other party.
 
Upvote 0

Kamac

Active Member
Licensed User
Longtime User
As a good file transfer you might take Dropbox application.
You may upload some files from your PC to their server, to your private part of it, which is password protected.
Then, using your mobile, you can use that application to download anything you've uploaded on it, straight to your mobile.
I think it is using FTP for that.

So straight answer would be to buy a server (There are also free ones, containing around 1GB-2GB space, they should do), then from your app using FTP:

Connect to your server's IP on port 80 would be good, because it is always opened.
Login with your username and password on it (Might be auto, so everyone can do that)
Upload your selected file.


The one who wanted to download it, does the same but :sign0161: downloads instead of Uploads.


Also, to fulfill it, you would need whole server which you can log-in such as skype does, to see all the devices.

That's a big deal to create.
 
Upvote 0

akgh2010

Member
Licensed User
Longtime User
Kamac, this is a :sign0142:
Dropbox is amazing...
Also I found another thread here posted by bluedude by the name:
Multipart upload through Mobypicture API (photo service) including the AdvancedCamera
the link should be:
http://www.b4x.com/forum/basic4andr...i-photo-service-including-advancedcamera.html
and it's a :sign0087: too
Well, I'm trying now to connect the dots...
If I find a whole idea, I'll post it here...
Thanks
 
Upvote 0

hackhack

Active Member
Licensed User
Longtime User
I'm not familiar with FTP applications that allow you to connect to devices. Can you post a link to such application?

Actually come to think of it, I've only tried it on wifi - so perhaps it doesn't work via the internet?

But otherwise I use FTP Server to run as an FTP server on say the tablet, and then anything on a PC or File Expert on an Android phone to pull files across.

My old Sony Ericsson symbian also runs an FTP server :)
 
Upvote 0

thedesolatesoul

Expert
Licensed User
Longtime User
There is a problem with running an FTP/HTTP/SSH server on the phone on 3G.
A lot of providers block ports, until opened by the device.
Since a server NEVER initiates a connection, the client will keep trying to initiate a connection but since the port is blocked it will never get through.

So basically forget about direct device2device communication since it will never be reliable if both devices are behind NAT.

You can use a server (even free ones to upload the file).

Or you can try dropbox. I am trying to write a library for that (but its painful :( )
 
Upvote 0

tansoftware

New Member
Licensed User
Longtime User
Simple Solution

Read the "Android Network Tutorial"

Client application
Steps required:
- Create and initialize a Socket object.
- Call Socket.Connect with the server address.
- Connection is done in the background. The Connected event is raised when the connection is ready or if it failed.
- Communicate with the other machine using Socket.InputStream to read data and Socket.OutputStream to write data.

Server application
Steps required:
- Create and initialize a ServerSocket object.
- Call ServerSocket.Listen to listen for incoming connections. This happens in the background.
- Once a connection is established the NewConnection event is raised and a Socket object is passed.
- Call ServerSocket.Listen if you want to accept more connections.
- Using the Socket object received, communicate with the client.

Very simple and straight forward.
 
Upvote 0
Top