I have go through several posts in the internet but did not get a straight and clear answer for this.
I am doing one app on android which needs data to be sent/received from a database over internet. So how I can send/receive messages from my remote database on my android device?
Is there any messaging framework available currently in the android to do this type of task?
One method I thought of is to have PHP scripts at my web server and I will call those php scripts from my android httpClient. But its a bit tire some and error checking also a bit problem and retry mechanism also not there.
Please suggest a good way.
Google have a service for that.
Google Cloud Messaging for Android
Google Cloud Messaging may be suitable just for sending push notifications to android devices and things like that. And XMPP could be used to send messages from one android to another. So what you have taken, using a PHP script and calling it using a URLConnection or HTTPConnection is a better way to make transaction with a remote database
Related
Is it possible for a device to send message to other devices using Google cloud messaging without an app server at all?
I have a centralized database using Google Cloud Datastore. The app will get required registration ids from the centralized database and the database is updated by all the devices. So, getting registration ids is not a problem.
Can this be done using upstream messaging? I am not sure because i have searched a lot but never saw an example where app server is not used for this purpose.
This question is not duplicate of another question, because here i have central database to store registration ids which is mentioned as a problem in another question.
In the most basic sense no, not at this time. You cannot send an upstream message from one device to another without an app server. You can create an app server on your device application but that is not recommended. The current recommendation would be to use an app server to facilitate your device to device messages.
To answer is it possible? Yes it is.
Sometime back I have created a POC to send GCM message to self, so I know its very much possible. I configured my GCM to work with any ip in developer console i.e. 0.0.0.0.
just use HTTP post to send your message from android as you would have done from Server.
Like (most) everything else, there is an API for that.
Google hosts its GCM service on GCM Connection Servers. The official document requires you to create an App Server to issue the API requests to the Connection Servers.
Alternatively you could setup the Connection Server to accept requests from any IP around the world, and then issue the requests via your client app. The API is here and it's quite simple.
Seurity issues
Bundling your API key with your app, and setting the Connection Server to unrestricted connections is an obvious major security issue.
Why bother?
Why bother doing all of this? Instead I would use a free service like Parse.com, which takes care of the users database and offers up to 1000000 messages a month free.
Has anyone actually done this. I would like to see example android project.
I've been doing a lot of research without success on finding a solution to my (simple) problem. I'm building an application that does not requires to be connected to the internet but it does consumes a restful API from a server installed in the local network LAN.
Currently I'm dispatching a HTTP request every minute to see if there were any changes in the DB and alert the user of said changes. However this is not very efficient and it results in a poor performance / battery drain.
I've heard that push notifications can be implemented using Google cloud messaging, but that is not an option since it requires to go through google servers, in other words, internet.
I'm using Square's Retrofit framework for handling HTTP requests on Android, and PHP + Laravel on the server side.
Is there a way to send push notifications? If not, is 'long polling' a good practice in Android? Will it even work with Retrofit?
On server side you can use an XMPP server, there are some XMPP servers such as Openfire, ejabberd and SleekXMPP. Please have a look at them.
On Android side you can use a client library e.g Smack or Xabber, the mobile library will automatically update with notifications or events using listeners.
I hope this helps.
I have no idea hot it works, but have you looked into specific packages like this one?
https://github.com/davibennun/laravel-push-notification
Some advice comrades, am thinking of developing an android app that retrieves some updates from a website. In other words when content of the website is updated the app content is also updated. I have searched google and i can't get clear answers on how to do it. Anyone tell me what do i need to do to accomplish this task. I have read about json parsing and web services but everything is not clear since am new to network apps.
If your server is a standard http server, you'll need another server that can establish a connection with the android device.
You can implement it yourself (using TCP or UDP), or you can use the trusted Google GCM:
https://developer.android.com/google/gcm/index.html
I recommend using GCM, but in either way, you'll have to make your current server, to notify the other server when it needs to send a message to any device.
I wondering any solution to make an real time chat like wechat or whatsapp. I having researching but most of them are just mention use 3rd parties server. I already have my LEMP server setup so I would like to use my own server instead of 3rd parties.
I mean if I have 10K download my app from either google or app store. I want them be able chat with one another in real time just like whatsapp. How can I let them retreive the new data that send by another user in real time without using any library or 3rd parties such as XMPP, PUSHER or PARSE?
Sorry for my grammar error. Any Suggestion apperciate.
If you have setup your web server communication could be done in real time web sockets https://www.websocket.org/ . You could send and receive messages in json formats . Also have a look at Stomp http://stomp.github.io/
I would recommend Websocket related solution.
Try Socket.io or Firebase. They are both easy to implementation similar function and are also scalable.
I'm very familiar with REST type of communication where the phone sends GET and POST messages to the server - essentially polling the server for updates. This worked well for apps where real-time data wasn't essential.
For a multiplayer game real-time data is essential; after a user has signed-in to the server the server needs to be able to send messages to the phone (instead of the phone asking for data).
Does anyone have any links to provide details on how this is done ?
Thanks to Selvin for pointing me to the "socket" keyword.
I've searched around and came up with the following online resources :
Incorporating Socket Programming into your Applications
http://thinkandroid.wordpress.com/2010/03/27/incorporating-socket-programming-into-your-applications/
Example: Android bi-directional network socket using AsyncTask
Example: Android bi-directional network socket using AsyncTask
If anyone has a book suggestion, please let me know with a comment.
You will need to implement Android Cloud to Device Messaging, Android's push technology, available on Android 2.2 and above.
http://android-developers.blogspot.com/2010/05/android-cloud-to-device-messaging.html