I am developing an Android app that allows sports team coaches to update the attendance for events like training/matches. A feature I would like to add would be to display a notification on the device to remind them that they need to update the attendance for the event when it has started.
I have been reading online a bit and it seems that push is the preferred method for data that is changing. But because i know the start times of the events, would it be better to create a background service using something like the following?
https://stackoverflow.com/a/9933130/2039505
I basically want the user to receive a vibrate notification which when they click on it, it will open the events attendance screen. Hopefully someone will have some insight into which option is best!
Since all you need is a notification on a timer, the AlarmManager would be the best way to go.
If you used Push Notifications(GCM), that would require server side code and a method to store the device id to send the notification to.
Overkill if you ask me.
Here are links to the official documentation and example code:
Official documentation
Vogella's example on services
Related
I'm investigating building a custom Do Not Disturb Android app, specifically regarding its notification masking ability.
What I want to happen is to activate a "routine" with specifics apps (by package name) tied to it, so that when the routine is running, if a notification from that app comes in, the notification isn't displayed until the routine is stopped (just like how Do Not Disturb does it).
Right now, what I've done is cancel the notification via the NotificationListenerService so it doesn't show up in the status bar, save the notifications details, then display those in an activity once the routine is stopped. It nearly accomplishes my goal, but I'd like to replicate the Do Not Disturb functionality if possible.
my app lets user create scheduled task.
Example: Tomorow show this notification => this notification leads to this activity etc.
What is the best practice to do this? Do I need to use some background task manager? How can I do this so it will work even when App is not running?
Facebook is doing something similar, when it is not running it still checks web for useful info for you.
Can somebody point me to some tutorial or get me some example? Thank you
There are several solutions that are recommended by Android framework team
Firebase JobDispatcher
GCM Network Manager, codelab
Job Scheduler api 21+
For showing a notification at a known point in the future (either a specific time or X hours from now) use AlarmManager to set an alarm.
For getting notifications from a server, generally you'd use push messages from the server. Although polling the server on an alarm would also work.
I want to create an app to consume real time data from an API. This API give me information about different temperatures. When a certain temperature is exceeded my app need to notify the event to the user.
This app need to run in Android and a web browser. So, my problem is the architecture... My app need to be a websocket or a REST API?
Any help is appreciated!!
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 addition to what #Xoce showed, Amazon has the SNS service which will push notifications to you. Or, if you application is a web based application inside of a native (i.e. Cordova), I've used PubNub for JavaScript based events.
A word of caution though - you'll need to define "real time" for your application. There will be a slight latency between the event and what your application sees no matter what stack you choose. When I think real time I think in terms of microseconds of delay. You may have seconds of delay. If this is a "hey, your house temperature is above a threshold" type of application then that is fine. If this is "hey, your nuclear reactor temperature is above a threshold" then this may not be the way to go.
I wanted to ask a question you have to see if I can help.
I've started working on a (Android) application that should display a message on the android device. This message should be Push notification type, as would be when we get a whatsapp, with the only difference that this message does not come out, but will be a sort of alarm, since the user will mark what time to leave this notice.
And want to know what kind of message should work, and if it's with Push notifications, if they know of any conditions or any manual tutorial, because I've seen so far the only thing that has made me lose more.
Thank you.
I think you don't need Push Notification but AlarmManger and NotificationManager samples.
http://androidideasblog.blogspot.co.uk/2011/07/alarmmanager-and-notificationmanager.html
i've a question for a feature, i want to implement.
I know some applications, like whatsapp, gmail or others, which run in background and notify the user, if something is received...
i'd like to do the same with my application. i've a http-network-connection and want to notify the user, even if he hasn't the application started. is something like this possible?
Is it possible, that a PopUp-Window, like receiving a sms, appears?
(if not, the notify-way in a titlebar is enough)
i've no idea, what i should google or where i can find help
Thank you a lot!
Edit: I found another very cool framework which deals with notifications. Have a loot at: https://www.parse.com/tutorials/android-push-notifications
You should take a look into Services. You can have the http connection listening in it. For the notification I'd use the NotificationManager class. A notification is much more less intrusive than a pop-up.
Hope that helps
Google Cloud Messaging will definitely help you.
If your server can instantiate this 'action' or 'event', by all means don't try to pull data periodically, coz that brings extra complexity to your app and also battery drain to your users.
But if you really, truly, badly need this behavior, you can instantiate a Service from your app's process. This can be done from many places, like your main activity or some other user action, or even from a broadcast listener. For example, our app has some parallel work to do, so we pass this to a service and that service is initiated by a broadcast listener listening for phone events like a phone call or sms.
On the other hand, just like the main activity of your app, your background service can be killed arbitrarily by the operating system any time. So you shouldn't depend on it running forever. You should have ways to check if that is still working in the background. Check alarm events or any other relevant broadcast listeners.