Can I set which days the alarm turns on with alarm manager? - android-studio

Alarm manager can save which days to trigger the alarm, case like in AlarmClock with
android.intent.extra.alarm.DAYS
Alarm.set(message, hour, min,daysOfweek[])
//////Alarm CLock Display/////
Walk 8:55 M W F S
How do I get alarm manager to do that so it fires on specific days?

Related

Anylogic: Resource(from the pool) is not being released when its availability time ( as per certain schedule) is over

In my ANYLOGIC model there are certain services( some delays the agent from 10 to 15 minutes, others 4 to 8 hrs), using certain resources from a resource pool.
The resources (pool) are available as per a well defined time ( Available: entire week except sunday , 10 am to 1:30 pm and then 2:00 Pm to 6 pm.).
I can see that once a service starts it continues till it finishes itself even after the resource availability time is over.
For example:
A resource is available :entire week except sunday , 10 am to 1:30 pm and then 2:00 Pm to 6 pm.
A service( of 8 hrs delay) starts from 12:30 pm....once it starts, it gets continue till it get finished. Practically it shall release resource from 1:30 to 2 pm and also if the task is not over then it shall not continue beyond 6 pm as well, and shall stop the same and start next day(or next availability).
but it does continue once it starts till it gets finished.
kindly suggest the specific area to be targeted to code or any other option is available?
Define your resource-pool downtimes using a Downtime block. Tick it's "may preempt other tasks" as below:
NOTE: play around with preemption as it interacts with Seize-preemption, resource pool preemption and priorities. Start simple and add complexity only when you fully understand how things work under the hood

email alerts for Azure Logic app runs failed

I want an email notification for every logic app run with Failed status like below screenshot.
I tried to configure Runs Failed alerts in logic app but things are not very clear to me.
what should be the excect entry for Threshold value, Operator , aggression type, Period and frequency to get alert notification on every failed run.
For this requirement, I think you can choose Static in "Threshold" and set condition as Great than Count 0. In "Evaluated based on", you can set 5 minutes as "Aggregation granularity (Period)" and set 5 minutes as "Frequency of evaluation". Shown as below screenshot:
The "Evaluated based on" you choose as 24hours and every 5 minutes is not particularly good. Because once the alert triggered, its "Monitor condition" will become "fired", and if it hasn't been solved, the alert will not be triggered again.(For example, your logic failed on 1:00, the alert will be triggered in 5 minutes. But it will not be triggered again if there is a failure during the last 24 hour when evaluate every 5 minutes).
By the way, you can also test it by yourself. You can create a logic app as below, it is allowed to be saved and will fail when run it.

Google App Engine cron job schedule repeat on days with DST changes

I have a cron job that should repeat every 3 hours and must land on 9:30 in US/NY time.
If I start the job at 0:30, and run it every 3 hours, will it run at 9:30 on daylight savings days?
The documentation is a bit vague on this: https://cloud.google.com/scheduler/docs/configuring/cron-job-schedules#daylight_savings_time. It uses wall clock time to start, but does it use wall-clock time for each offset as well?
Alternatively, could I start it using 9:30 as the trigger time, and then every 3 hours until 6:30am the next day?
As you mentioned, Cloud scheduler uses wall clock time, is expected that the executions changes according the wall time.
To run a job from 9:30am to 6:30am (next day) you need 2 Scheduler jobs
1st will be run every 3 hours starting 9:30 to 23:30
30 9/3 * * *
2nd will be run every 3 hours starting 0:30 to 6:30
30 0-6/3 * * *
I use this page when I have doubts about cron format
The best way to completely avoid any kind of issue with DST changes is to switch to a timezone unaffected by those, as the documentation states:
If your job requires a very specific cadence, you may want to consider choosing time zones that do not observe daylight savings time.
A good one would be UTC for example, and as the difference between NY(GMT -4) and UTC(GMT) is 4h you just need to add 4 to your desired starting time.
With that you are assuring that the scheduled hours do not get modified and whatever you are expecting to be run is done as it should.
Regarding the start time of the trigger, it does not matter whether it is 0:30 or 9:30, once you create it, it will run every X hours/mins/seconds as you will have it specified beforehand.

How to prevent Application Insights Availability feature to send alerts every 5 minutes?

I use Application Insights "Availability" feature to check a web site availability and send an alert if it is down.
Now Application Insights sends an alert every 5 minutes, even the "alert failure time window" is 15 minutes. Test frequency is 5 minutes.
So I get an alert after 5 minutes, then after 10 minutes, then after 15 minutes! I get 3 alerts while I need only 1 one alert after 15 minutes. It looks like a bug for me.
How to prevent Application Insights Availability feature to send alerts every 5 minutes?
The email (notification) is sent the moment alert condition is satisfied. It doesn't wait for alert failure time window.
Example: for alerting rule to send notification if 3 locations out of 5 turn red, and 3 locations turning red within the first second => notification will be sent during the same second. It will not wait for 5 (or 15) minutes.
This is by design with the goal to reduce TTD (time to detect).
There are two ways to handle noise:
Configure retries (test will retry 2 times during red => green state switch)
Increase the number of locations to trigger alert (for instance, 14 out of 16)
Either way - only one notification is supposed to be sent, not every 5/15 minutes. Multiple notifications suggest either some bug in tracking current state of an alert (bug in a product) or an Application which intermittently fails (so, alerting rule constantly changes its states green => red => green => ..., as a result email is sent during every transition). Do you get alert every 5 minutes when tests are red all the time?
Alert failure time window defines what failed location means. 5 min test interval and 5 min alert failure means that 1 last result defines whether location failed or not. 5 min test interval and 15 min alert failure means that 3 last results define whether location failed or not. So, if one of those 3 test runs failed then location is considered as failed (even though 2 results after it might have been successes).
Increasing alert failure time window makes alerting rule more aggressive (and noisy for intermittently failing apps).

How to detect inactivity/idle time since last keypressed on j2me

I have an application with a lot of screens (followed by MVC pattern), and I want to be able to receive in a fashion way the information that last key was pressed x seconds ago (120 sec let's say). Is there standard way to do this or I have to start a timer and every time when I pressed a key I have to override a variable and in the timer I have to check the difference time between that time and current time?
Yes, just record the system timer when a key is pressed.
long epoch = System.currentTimeMillis();
When a key is pressed again, you need to check the time difference to see how long it's been idle for.
If you need to trigger things without keypresses, then you need to start a thread which wakes now and again to check the elapsed time, and trigger an event of some kind when the time period has elapsed.

Resources