Google Cloud Messaging and MySQL database - java

I want to use Google Cloud Messaging for my app for both upstream and downstream use, using xmpp. However I am wondering how I can select and input data to and from my MySQL database to be sent over the GCM network.
Can I use PHP with GCM or do I have to use Java or Python?

GCM is used for sending messages FROM server TO your android application. Also a GCM message can only carry a maximum of 4KB Only.
So in my opinion, send data to your MySQL db directly from the app (If you want to make this asynchronous, look into Android Sync Adapter); and for sending data from server to your application asynchronously, send a ping to your app using GCM (it can be any short message), so your app can undergo a normal http request-response procedure to get the data from MySQL.
For more information of Sync Adapters: http://developer.android.com/training/sync-adapters/index.html
And for a tutorial on a simple GCM using PHP: http://www.programming-techniques.com/2014/01/google-cloud-messaging-gcm-in-android.html

There are XMPP libraries for PHP. See https://code.google.com/p/xmpphp/ for example.
So, PHP is possible, however i would really like to hear what is a recommended approach, as im going to implement it too.

Related

Is it Possible to run both Server and Client android applications Locally?

I'm looking to program a network application. I was going through: http://www.stanford.edu/class/ee368/Android/Tutorial-3-Server-Client-Communication-for-Android.pdf which talk about server and client programming for android. Now imagine I don't have an internet connection and I want both server and client applications run on either same android device or different android devices locally.
Is it possible to develop and run both server and client applications using TCPIP/UDP/Multicast locally on either standalone android device or multiple android device?
Yes, it is possible to communicate between Android devices or applications that are not connected to the Internet.
If you are using different devices, you probably want to use sockets, but it is possible to run an HTTP server on the server device and then use HTTP. Make sure they are connected to the same wifi network.
There are several different ways to communicate between different processes on the same Android device. The easiest might be to use a Messenger service but sockets and HTTP are also possible here.
Yes, it is possible in some manner.You can either use sqlite database present in android device to store various types of data in table form and data retreive from same.
Another way is to use Parse cloud as a server or backend of your client application.It allows your app to run even when you are not connected to internet.It stores the data in cache memory with its api and then uploads data to the server cloud as soon as you get connected to Intenet.
You can ask if you have any further queries. :)

Data push in Android from a Java server

I am developing an Android application that connects to a Java server (with sockets). How I can do to make the server send data to clients when some data is changed on the server?
i would recommend using googles push services:
http://developer.android.com/google/gcm/index.html
that way you don't need a static connection to the server, but just fetch new data from the server if the client receives a push notification (or- if the information is not too big, you can add it as payload to the push notification).
alternatively if you want to support multiple platforms you could also take a look at services like urban airship:
http://urbanairship.com/

Create a basic network app

I have a little question about an android app with a function "remote" use via internet.
So I have these ideas:
Create a webservice using php on the server, and refresh the client app all x time like 4-5 sec
Or make a java server (so I don't know how I can do that)
I just want make a remote connected via user/password to the server and the other app connect to the server and refresh his status.
Do you know the best way for do that?
Thanks
The question is not very precise, but as far as I understand it, both your ideas implement the 'pull' concept, that is the client app checking the status of the server every now and then.
If you want the app to be instantly notified of the server status change, I would suggest push notifications with GCM (Google Clound Messaging). You can find some basic descriptions and examples at: http://developer.android.com/google/gcm/index.html
Sending a server-to-client notification is simple regardless of the platform you use server side. E.g. for PHP integration with GCM, check out this thread: GCM with PHP (Google Cloud Messaging)

How do I send data to an android app from Google App Engine?

As I understand it, there are two ways to send data from GAE to my app:
The app does a request and the server sends the data as a response.
The server sends the data directly to the app without the app doing a request.
I know how to send data with (1) but how do I send data with (2)?
It seems you are looking for Google Cloud messaging which helps "Push"ing the messages from your server to your app (via GCM Service)
Read for details
http://developer.android.com/guide/google/gcm/index.html

Check File in the server is change or not

I am trying to make an app that connect to the server.
The app is used by some devices.
If one of the devices upload something to the server, I would like other devices receive the notification about the server has something new.
My question is, how to check the server is change or not? How often we must check the server?
I wonder how the Online Messaging work, because someone send something, we receive the message ASAP
Is the concept can be use with my app?
Sounds like you want to take advantage of Google Could Messaging or GCM for short.
http://developer.android.com/guide/google/gcm/index.html
This could be a lightweight message telling the Android application that there is new data to be fetched from the server (for instance, a movie uploaded by a friend), or it could be a message containing up to 4kb of payload data (so apps like instant messaging can consume the message directly).
GCM is the standard for how your apps "talk" to your servers. Either for a message in it's entirety or just a message to go check the server because it's been updated.

Categories

Resources