So I have a desktop app working with an MySQL DB. I need to include a notification system inside that desktop app, allowing the desktop users to send notifications to a set of 10 tablets. So it's like sending SMS, but not really.
So the tablets users must receive the notifications sent by desktop users and the other way around, tablet users must be able to send notifications to desktop users.
Since the common ground between the two is the MySQL DB, I thought of the following schema:I would need to build a notification service, that will run all the time on the tablet after I run it once. It should check a remote MySQL table to see if new records are inside, and if so, then display a notification on the tablet.
I am sure many of you experts have done this at least once.
So the path I thought of is:
I have a MySQL db on a server, and I have an application (desktop) that allows users to input a notification (a new record) inside a mysql table.
Build a PHP backend that will serve my Android service with "yes" or "no" answers and a second PHP that will return the data of the notification upon request
Build a service that will make a call to that PHP every minute
In case "yes" is received by service then make another call to the second PHP asking for notification data
With the response, create a notification on the device and show it to the user.
Now,
First of all,: is my logic ok?
Second: How do I create a service that "installs itself" and remains installed and running all the time on the tablet? I've been trying the tutorial from here but the service does not do what is should. Perhaps it's because of RECEIVE_BOOT_COMPLETED ?
Third:Should I make async calls to the PHP, or is it enough to make simple calls, since there is no Activity/Intent that would freeze until receiving response
Fourth: Is it possible as I imagined to have all this as an independent service, so not an Android App that the tablet users must run and keep open?
Is there any good example out there of a service like this?
I found an example of something very similar to what I want (I think) but I have a few questions about it. So the tutorial is here
My questions are:
1. Will this service start on Android startUp ? Or do I have to do something extra? What would that be?
2. Where do I place my call towards PHP?
Please help me,
Thank you
I would suggest that you make your database on the tablet a ContentProvider.
Then you can implement syncing using the sync mechanism.
http://developer.android.com/training/sync-adapters/index.html
To trigger the update on the devices look at Google Cloud Messaging.
http://developer.android.com/training/cloudsync/gcm.html
I haven't done this, but I have been researching it :-)
Related
I'm building an app that currently can receive data from an SQL database through the click of a button.
How can I automate the app (so I don't need the button) so it receives the data constantly (or every x seconds I don't mind) and then sends a notification to the user if certain data has come through. I need the data receiving and checking to be done even when the app is minimized/not on the user's screen. I've heard talk of using 'services' but i'm relatively new to app dev so no idea on the matter.
Any help appreciated,
Cheers.
If you're new to android programming is a bit complex but you can implement this functionality using:
- Services: sends request to the server every x seconds(manually)
-Sync Adapter: (you need to know services ) android mechanism for doing exactly what you want.
More at: https://developer.android.com/training/sync-adapters/creating-sync-adapter.html
EDIT: you could also use firebase to send push notification
There is a scenario where I have to communicate from one android device to another android device (Far Away). But without using any server or sms service. Although I do have an active internet connection. I found a way through GCM, as GCM service provide data upstream as well as data downstream.
I want to know is there anymore way of doing this ?
You need a notification service, and google has something like that for us...
how does this works??
Take a look at the image below,
you need to register your android app in the google service, and your web interface will need an id, so everytime you want to push something to the android, your web interface instead will push it to the google server with the Id of the app, then google (no matter how) will localize your app, and even if its not running, they will get the notification,
behind the scenes there is a couple of thing that you must do, bu nothing like launching rockets from the NASA.
I will suggest to take a look to some tutorials
in order to start with the registration of your app, get the api key etc etc..
In your case
you will need the id of the other phone, so you can push it data.
I am pretty new to the mobile development scene and there is a very basic question to which I cannot seem to find the answer. Here is the scenario.
I have a mobile application. That application is connected to a server that I own. To use the mobile application, users have to login using unique credentials. Now lets say there are certain events on my server, about which I want to notify a particular mobile application user. Can my server proactively send a signal / data to the particular mobile app instance [using sessions data perhaps] so that a notification can be displayed on their screen?
Polling by mobile application towards the server to look for such events is not allowed / feasible.
I can speak to an iOS solution. Android surely has very similar functionality.
There are 2 ways to accomplish this:
Silent push notifications
Background fetch
A silent push notification can be, well uh, pushed to devices without alerting the users. This means that upon reception of the notification, the app can start downloading what it needs from your server. You will need to set up proper backgrounding for this to work properly. Otherwise, the notifications will be queued up and will only take effect when the user opens your app the next time. Start here for push notifications. The payload you send is what controls the notification.
Background fetching is process where your iOS app gets woken up by the operating system (iOS) periodically to allow you to perform a task. This task can be fetch data from a server or anything else you want pretty much. This is probably the best of the 2 solutions given that push notifications are not guaranteed to be received and this puts the onus back onto each device to fetch their own data as opposed to you creating a whole back-end system to perform the push notifications. Start here for background fetches.
You mean something like push notifications? You can read this tutorial (or any other tutorial on google) about how to implement push notifications in your app:
http://www.vogella.com/tutorials/AndroidCloudToDeviceMessaging/article.html
Lookup about push notifications on each of the platforms you're talking about.
Plus look into some live web apps, two that come to mind are meteor.com and nodejs
I've some knowledge on databases. I've used them for some android projects, but recently I am in the need of making a website in which someone can see the data of each table that is accessible to them. The problem is that they must be able to change this data, and this change must replicate into the android app that the users use to upload their data.
E.g:
Users upload their ringtone, someone using this website decides that they need ANOTHER ringtone. It is changed, and now this change should appear on the other person's phone and be used as the ringtone. This must be instant because speed is crucial. Please tell me if you know of documentation or something similar to this. Greatly appreciated.
This is easy. Use a SQL trigger to populate an audit table. Then a service to process the audit table and send push notifications to mobile. Push notifications are instant. The service can be configured to process every 10 seconds or so. You can tweak the service interval but whatever you do, do not try and send the push notification inside the trigger. Use the audit table.
Prior to posting this query here, I have gone through a similar requirement by a user in the post here
Based on research, what I understand is, push notification concept can be used to notify the application of any changes happening in the server, if and only if, the server control rests with us.
I have made an application which would display the data from a mobile website. Is there a way out by which I can notify the handset user of any change happening in the server, such that the user gets an alert in his handset, so that he can open the application and see what is the new addition/change that has occurred in the website, when I have no control over the server? Pardon me , if I sound totally dumb with this question. Had such a requirement and was curious to know the way out, if any.
This way you should build your own web service which will poll other service for changing and then push alert to android device via Google Cloud Messaging for Android (GCM).
But you also can poll this service with your own application in background service. This method is very bad because of battery drain and network connection using, but this is no need for 3rd party services
try noczone.com, they have custom notification service with an easy to use PHP sdk
https://noczone.com/?page=custom_alerts_sdk
i use it to let me know whenever i receive a support ticket or any new registrations.
and you will need to have their app installed to receive notifications on it
https://play.google.com/store/apps/details?id=com.wr.noc