Reputation: 115
Just a quick question which i have been trying to search up on google and well came with results that do not fully satisfy what i am looking for. What I want to develop are two apps one that essentially only i can see and work with, so the main app and then another one on the client side. The client app will only see what i send them from my app.
The question I want to ask is, is this possible? i have found tutorials on how to do app to app communications but when they are doing this in the tutorial, the app they want to communication with is on their phone already. But my apps will be on different phones far from each other. does this concept still work.
My main reason to do this, to avoid server connection from android app to mysql and then the client side also does server connection to retrieve the info since my understanding of the mysql database connection from android is minimal to zero right now.
Upvotes: 2
Views: 1084
Reputation: 10288
In order to have two apps "communication" you need a connection - TCP/IP (WiFi/network), Bluetooth, etc. If they are "far away" then it's a network connection.
In order to use TCP/IP the device needs an "IP Address" - this is assigned by the carrier, the WiFi network it's connected to, etc. Since these IP addresses change over time, you cannot rely on it. It's like trying to send a letter to someone that always has a different house address. Each time, you need to ask where to send it. However, you can only ask using a letter - so if it changes before you ask, you can't communicate until they contact you. But if your device does the same thing, then you will quickly be unable to communicate.
Therefore, you need a "static IP" address (a server) and a "lookup table" - a way to identify the device you are wanting to contact (like a username or phone number) and then you can get the IP when that devices tells the server what it is. Likewise, your device can tell the server what your IP address is.
However, that's a lot of work for you, for the networks and for the devices. This is the reason that Google made Google Cloud Messaging (GCM). It does most of that - including queuing messages when the device is not available, keeping accurate and up to date device addresses, message delivery verification, server up-time, etc.
This is called "push" notifications because the server knows where to "push" a message to when you want it done.
EDIT: You have to create the "lookup table" - GCM will track ID's for devices and IP addresses, but you probably don't want every device to store the table of "all devices" - you just want a list of "contacts" (a subset of "all devices"). Unless you are building this for a very small group, then you need a server to handle that.
There are many alternatives to GCM - Parse, Quickblox, etc. or build your own XMPP server. But if you're not comfortable with SQLite, then an "out of the box" solution is best.
Also, this is probably much, much harder than you realize. But to me it's a fun and interesting aspect of mobile devices.
Upvotes: 2