问题
What is the general communication architecture for two android applications?
Case 1:
I have two android applications,
a) One is a server that waits for client request, process the request( read data from some sqlite db) and return the results to the client. This server application runs on its own independent android phone.
b) The second is the client that sends the request to the server application in (a) and it too runs on its own independent android phone.
Question is, do the two applications have to go through the Mobile Service Provider to enable communication? or they can just talk to each other directly via some public IP/WIFi etc. What is the communication structure/architecture for this applications?
Case 2:
I have an android application running on an independent android phone, and i want it to talk to some server application (Web Server / Application Server) running in some machine somewhere on the internet, sends request and get some feed back.
Again, do the two applications have to go through the Mobile Service Provider to facilitate communication? or they just establish a straight TCP/IP communication via some public IP?
Any reference articles would really help.
Thanks
Gath
回答1:
Question is, do the two applications have to go through the Mobile Service Provider to enable communication?
If you want to use 3G, yes. If you want to use WiFi, no. Generally, Android applications do not care where the Internet connection comes from.
or they can just talk to each other directly via some public IP/WIFi etc.
If they have a WiFi connection, they have a WiFi connection. What you do with that WiFi connection is up to you, using Java sockets, and respecting all the normal problems with Internet access (e.g., NATs).
Again, do the two applications have to go through the Mobile Service Provider to facilitate communication? or they just establish a straight TCP/IP communication via some public IP?
You ask for a Java socket. You get a Java socket. You do something with the Java socket. Where that Java socket comes from and how its connection works is generally under the covers: 3G, WiFi, a squadron of very tiny passenger pigeons, etc.
回答2:
I'd suggest Android – IPC, aidl and IBinder and Grasping Android's IPC mechanism for a start. After that just hunt on Google for 'Android IPC'
回答3:
Something about sync is here Synchronization in Android
来源:https://stackoverflow.com/questions/1617925/how-do-two-android-applications-talk-to-each-other