My app is an Android app for booking tables.so the app directly communicating with the server.I need to call a specific event that is generated by the Android app.say an item is purchased by the Android app, so I need to hold that item for 2 hour so no one can use that item.i'm thinking change the flag inside the database to not available. After the use that is after 2 hour I need to release the item for the other users.
I know from trigger will done the job but is it possible to delete the crown trigger from the table and remove the scheduling.
Why would you hold/release like that? It doesn't seem robust... if there's some kind of communication error, the bike could get hung up permanently. I would run something based off timestamps and calculate the bike's availability in realtime based on the date. These calculations are going to be cheap to do.
If you want to handle this on the client side then you have to do it using AlarmManager, schedule an event to make an api call or just release it locally. But as u said cron job will be a better way to do it where u update the db after 2 hrs.
If you want to run particular Rest API
, after every 2 hr , You can either set Repeating ALARM , or you can user Timer and Timer Task
OR
If you want to just notify the user after 2 hr,
Then you can use cron-trigger with cloud messaging like FCM (firebase clod messaging )
Related
I have an android app which reminds user to their specific Work at any Date and time that saved on database.
I want to create functionality that changes user work status after 30 min of their work time and for this I have to check in the Database every day and every second that Is there any work now?
I can use scheduler in spring boot, but how can I apply database stored time to run this schedule task?
There may possibly of no work then, there will be unnnecessary calls.
How can I apply condition that Scheduler must be call only when Work is ready?
I want this app to function like this
1.it will send the user location along with a message at interval of 2 mins to preselected contacts.
2.Location should be as presice as possible.
3.it should run in backround.
4.it stops only when the user stops it.
I tried many ways but it would work in foreground I want this to waork even when the app is closed if the user has to stop it he would have to open the app and deactivate it.
The IntentService class provides a straightforward structure for running an operation on a single background thread
See https://developer.android.com/training/run-background-service/create-service.html
I have a database with datas and my android application when it was launched checks if there is a new record in the database.
I created a Service and it checks every ten seconds if there is a new record and alert me with a notification.
I think it isn't the best solution cause it checks every ten seconds so it use the battery and internet every ten seconds.
Is there another solution to do that without check every ten seconds, for example, by using some code in my php form which add content in my database.
Thanks in advance.
You are right, there is plenty of solutions.
One of powerfull solutions is implementation of publish subscribe pattern.
In short: All subscribed clients will be notified on any change for which they are subscribed.
For quick info and start point use this link: https://developers.google.com/cloud/samples/mbs/pubsub_messaging.
General about publish subscribe: http://docs.oracle.com/cd/E19798-01/821-1841/bnced/index.html
Scenario:
There's a task-manager application that allows its users to create tasks and associate a timestamp with it.
Goal:
The application is supposed to send email alerts to the users at the time when any of their tasks are due.
Question:
If there's a function in the application sendEmailAlerts, which queries database, fetches all those tasks which are due now, and send their creators alerts; is it possible to trigger this function exactly at the moment when a task is due?
The approach that I have in mind is to use a Quartz job, that would run every x minutes and invoke sendEmailAlerts. But this approach doesn't seem very efficient. Is there any better way of doing it?
Thank you for your help.
You could use SQL Server Agent to create a job to execute at a specified time, although in this scenario i don't think it's optimal to create x jobs for x alerts.
how can i start/stop a specific service based on the following:
user A call user B ( the trigger is user B answer the phone and service stopped when call is ended )
user B call user A ( the trigger is user A answer the phone and service stopped when call is ended )
i want to calculate the call duration of the call and store the result in database.
regards
The calculation of the call duration is already done for you. Use the CallLog content provider, please.
Even if for some strange reason using the official call log is not what you want, you do not need a service. Set up a manifest-registered BroadcastReceiver for ACTION_PHONE_STATE_CHANGED and store the start/stop times in the database. Do not have a Service hanging out in memory for the sole purpose of watching time tick by.
But, please, just use the CallLog, since the OS is doing this work for you, and you don't waste the user's battery doing duplicate work.