Creating Notifications for Task Management App (Java & Firebase) - java

I want to create a notification system for my Task Management Application Which Stores the Task Title, Description, Time and Date (As Strings) on Firebase. I tried several methods Available on YouTube but I was only able to Trigger the notification but the Title and Description are not being sent to the Notification Channel which ends into sending an Empty Notification and I want to create notification for certain date and time too. The Triggered Notifications were only triggered when I manually set the time in code and not when I set the time and date from App.
(The method I tried worked only for Android 10)
I want to get the Task Title and Description and Trigger the notification at the time and date set by the user.

Related

Checking for new data arrival from a RSS feed

I made a RSS reader app for android and it gets the latest news from a RSS feed. I want to show a Notification to the user when a news is published to the website or the RSS feed. How can I check for new data?
You can create something which is called polling. Actually many rss reader apps using polling technique in which their
service wakes up at a regular interval to contact a server to see if new data needs to be processed.
This means that the application needs to wake up to look for new data even if none is
available to be processed. Read about IntentService and AlarmManager. Basically you can create AlarmManager which is going to start every amount of time that you want for example every hour. Than you can start a service which is going to check is new data available. If it is new data for processed available raise a notification on user phone. Set AlarmManager to fires up again for an hour and the service should shutt down itself. Hope this will help.

Background Service that makes an HTTP Request every 15 Mins

I am trying to implement a background service that makes an HTTP request to an API every 15mins for the whole day, starting when a certain activity is started. I need the service to be started every 15 minutes even if my application is not running or I am in another activity of that application. I've searched for an example for how to proceed an have looked at some Stackoverflow questions and answers for example: Start Android Service after every 5 minutes. which linked to this page : http://code4reference.com/2012/07/tutorial-on-android-alarmmanager/
From the discussion I know that I need to use an alarm manager, however all the implementations do not have this being done in the same activity they have broadcast receiver. The reason I would want to have the implementation in the same activity is because the results of the request is what I want to display on the UI.
Is there a way of implementing an alarm manager in this type of situation
however all the implementations do not have this being done in the same activity they have broadcast receiver
That is because that is your only viable option, and even that will not work well on Android 6.0+. The recipe for using AlarmManager for this sort of scenario is to have it start a WakefulBroadcastReceiver, which in turn will work with an IntentService to do the work and go away when the work is completed.
On Android 6.0+, courtesy of "Doze mode", your AlarmManager events will not fire every 15 minutes, if the device is not charging and not moving. Also, courtesy of "app standby" on Android 6.0+, your AlarmManager events will not fire every 15 minutes, if the user has not been in your application's UI for some time and the device is not charging.
The reason I would want to have the implementation in the same activity is because the results of the request is what I want to display on the UI.
This runs counter to an earlier statement that you made:
I need the service to be started every 15 minutes even if my application is not running
If your application is not running, then you do not have an activity.
You are welcome to have your IntentService post a message on an event bus, such as greenrobot's EventBus, to let your activity know about the results of the work... if the activity happens to be around (otherwise, the message will be ignored).

Schedule Tasks in AppEngine

I use appengine (java) as a backend for a mobile app (android). The user of my app can create public events consisting of a title and a date/time. Those events are stored on my appengine backend. Any user can subscribe for events and will receive a push notification at that time the events starts.
So I want to schedule a job / task on appengine to run at the events date/time to send a push notification to all subscribers.
Example:
User A creates an event that will start on Saturday next week on 8 pm. User B and User B subscribe for this event.
On Saturday 8 pm a job/task should start to send the push notifications to User B and User C to inform that the event has started.
My question is:
How do I implement something like this in an efficient way on appengine? I want to say, start a Task for the Event on Saturday at 8 pm. There are Cronjobs and TaskQueues. Cronjobs can not be created programmatically. TaskQueue needs to be pulled and can not be scheduled to pull at a given date / time, right?
So the only solutions I see is to create a cronjob that will run every minute to check if there is a Event that starts right now.
An event can be created at any time and any day in the week. However the most events are created for the weekend and There are days when no event has been created for. So running a cronjob periodically ever minute is very inefficient. Im looking for a smarter solution, any ideas?
Indeed, based on your description, the solution is to create a cron job that checks for new events that start right now.
However, you should be careful not to exceed the 60 second window you have for each cron job. If you have a lot of events, you probably should move the actual processing from the cron job to background tasks using Push Task Queues.
You may take a look to this post for a combination of cron jobs and Task Queues.

how to delete a android notification?

I want to push a notification to the user every X minutes.
However if there already exist an unread notification,
I want to delete it and replace it with a new one. How can I delete?
How can I check how many unread notification my app has already pushed?
To replace an existing notification with a new one you should simply post a notification with the same id, this behavior is mentioned in the documentation of NotificationManager's notify() method. If you want to just remove a notification, call cancel() providing the id you used to start it.
Regarding counting the number of notifications your app has sent, I think the best solution would be to just store a counter and increment it once a notification has been sent.

Background Process, no user interaction - android

I have an app in Android where the user can refresh his data manually (Example: Consumed sms, Total Balance ... ).
However I need a new feature:
- Implement a schedulle or alarm, where the data of the user will be refreshed every morning without user interaction (Background Process)
I tried with Services class... But I have not clear yet
Thanks

Categories

Resources