i am developing an restaurant menu app in android for Samsung galaxy tab. On my app user will select the food item and user will place an order. The list of items to be served is dispatched to the server through SOAP service. Now as soon as the the order get placed from the kitchen i want to notify the user that an order has been dispatched.
What i got while searching is that i can use PUSH Technology i.e. C2DM Cloud to Device Messanging. But i had not got proper code to use this in my app. Can any one give me a proper implementation of C2DM in android?
There are many push technologies. Another option is to use XMPP, as it will work on Android.
You can check Smack and asmack for XMPP. The asmack project is an Android specific derivitive of Smack, although there are people using Smack directly as well.
Related
I have built a Java Spring Application. This application in the end after doing its work pushes data to a sqlite database.
Now the functionality that i want to add is: Once data is pushed into db, i want to send a custom notification on an app running on android wear. This custom notification should have a message and some options for user to respond to. Finally on seeing the notification on android wear the user should select one of the options and that should be stored in a database.
As i am new to android development, I cannot understand three things:
1. What kind of android application should i develop?
2. How can this android application receive some message or data from some other service (in my case java application)?
3. How to save user response to database?
Some guidance would be really appreciated.
Thanks
I will try to answer all your questions. If your current Java application is a web app, then you will end up building a mobile/wearable app that will communicate to this web app. If your current Java application is not a web app, you will either have to integrate its logic into the mobile/wearable app directly or turn it into a web app so it can communicate with the mobile/wearable app.
You will end up developing two Android apps, essentially. A mobile app for the mobile device and a wearable app that will communicate with the mobile app. This can all be done in Android Studio and in one project though, so it will basically be one application at the end of the day.
Like I mentioned above, you will have to either integrate that existing application's logic directly into your new Android mobile app, or turn your Spring app into a web app and host it on a server that your Android mobile app can call out to to get data.
Android has the concept of local databases and can actually use SQLite on the device. This is most likely how you would store the response from your service.
I have apps on Android & iOS, & I need to send push-notifications to them from Java-server.
Please tell me, where can I find guides how to do this? I'm looking GCM & APN for Android.
https://firebase.google.com/
That is what I use for project and I am satisfied with it.
You have all needed tutorials and docs to start working with it.
Overview:
firebase provides You with Admin SDK wich helps You build Data and Notification messages and send it to firebase, firebase then sends it to either iOS or Android if You send it to specific client or to both if You send it to some created topic.
It also have easy to use Android, iOS, JavaScript libs to handle it on client-side.
ofc to get this work with Your server Client must generate notification token from provided google api and send it to Your server to store in DB.
there are some restriction though with push notifications 2kb if I remember correctly and 4kb for data messages keep it in mind when you create your communication architecture :)
I am building push notification server for android and web with third party java server. As we know to be a part of this scenario, corresponding android device should get a Registration id for GCM server and share it with third party java server.
Can we move this functionality to third party java server? Specifically, can we obtain a unique registration using third party java server and then assign it to corresponding android app?
can we obtain a unique registration using third party java server and then assign it to corresponding android app?
no, you can't. and actually it does not make any scene, because there are two options:
corresponding app == your app. if that's the case - then nothing stops you from maintaining regId for itself.
corresponding app != your app. it does no make any sense that google will allow any app to register any other app to receive GCM messages without the receiving app permission.
also I believe that what you have in mind is a common mistake:
GCM push != status bar Notification
when understanding that - you relize that it does not make any scense to register apps that not implemented integration with your server, because event if you could (and you can't) send other apps GCM messages - if they did not implemented a broadcast receiver or Service which handles your specific push parameters and trigger it to show notification or something, nothing will happened form itself.
No, that is not possible. Registration IDs are assigned to devices by GCM and there is no functionality to modify this process.
You could create a file on your server that generates a registration id whenever a device registers (But the device should not use GCM) and return it back afterwards. But to do this you also need to create your own "GCM like" library that would work for your server. Well, it may take a while but i think this is possible.
I wonder what are the ways/patterns to detect app uninstallation for any kind of analytics on android? I know the limitations of ACTION_PACKAGE_REMOVED intent - not received by application being removed. I am using flurry at the moment and have also discovered that they do not provide any kind of support for deinstallation events. This type of event is definitely something you want in your analytics but so far have not found any clear solution. Any ideas?
Here's a possible approach. In your Android app, implement support for receiving push messages from Google Cloud Messaging (GGM). Then, implement a server that sends GCM "are you there?" messages to all users at regular intervals (e.g. daily). Google's GCM service will notify your service of all targeted recipients which no longer have your app installed. To correlate uninstall data with other metrics such as app version, user demographics, date of installation, etc, collect that data in your app and supply it to your server when registering for GCM messages. Then when you get notified of an uninstall, match it with the installation data. From there, you could report it to a service like Google Analytics for additional slicing and dicing, graphical visualization, date range comparison, etc.
I currently have an small application that I have been using to learn java/android programming. Right now I have a setup were the app on one phone sends a request (via sms) to another phone running the same app. The remote phone receives the request and sends back some info. Next I would like to try this from the web. Is there an established "best" way to to this?
I was thinking I would have a web server send requests to the device via google cloud messaging and then have the device return the data directly to the web server. (Not that I really know how to do any of that just yet).
I see that there is a google cloud messaging return path (send messages from the device to the google cloud server, but it seems very new, do I need something like that? The main thing I want is to be able to ask the phone to do something when I want, not have it poll to see if there is a request, or just periodically update some status.
UPDATE:
Thanks to the answers below for confirming to me that I was on the right track.
I now have some basic functionality.
I started out using this gcm android demo code
https://code.google.com/p/gcm/source/browse/#git%2Fgcm-client%2Fsrc%2Fcom%2Fgoogle%2Fandroid%2Fgcm%2Fdemo%2Fapp%253Fstate%253Dclosed
and this ruby gem
https://github.com/spacialdb/gcm/blob/master/README.md
between the above two I was able to send a message to my phone pretty easily.
To get the round trip working, I setup a very simple rails app on heroku.
I included a modified version of the sample code in the gcm gem in a controller and then used
HttpPatch (needed for rails 4) to send a post/patch from my phone to my web app, the controller then echoes the message back to my phone.
I guess it would be nice to get the two way gcm stuff to work, but I am not sure there are any gems that handle that, and I am not qualified to handle a task like that :)
I would say it's the right call: Google Cloud Messaging for Android
From the site Android Developer:
This could be a lightweight message telling your app 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).
In this case you don't want to fetch data from the server but you want to send them.
You can send them in different ways. I would suggest, since you are learning, to try a RESTful solution using one of the implementation of JAX-RS.
As a short and direct answer for beginner : GCM (Google Cloud Messaging) would solve your issue. However, if your app turned out to be something bigger, other more technical and complicated solutions are present too.
see this link.