I'm creating an blackberry application. i want to invoke a method on a particular date.. i.e scheduling the process.
Just use method schedule(TimerTask task, Date time) for Timer object in your application: .
Related
I use the in local notation repeatInterval, Is it possible to retrieve what time the repeatInterval will work again? I need this to update the counter "how much is left before triggering the notification".
If you're targeting iOS 10+ you should use UNUserNotificationCenter.
UNUserNotificationCenter has method getPendingNotificationRequests(completionHandler:) that will return in completion handler list of pending notification requests.
Each element of the list is UNNotificationRequest object, which contain property trigger.
If the trigger is UNTimeIntervalNotificationTrigger or UNCalendarNotificationTrigger it has method nextTriggerDate() which will give you the timepoint when it should be triggered next time.
And it looks like what are you looking for.
I'm I obliged to pass either UIApplicationBackgroundFetchIntervalMinimum or UIApplicationBackgroundFetchIntervalNever ?
Or Is it possible to pass a custom interval instead, for example 10 minutes:
UIApplication.sharedApplication().setMinimumBackgroundFetchInterval(600.0)
In my App, I have to download some new updated data while the app is in the background.
Then I'll use the new data to send a local notification to the user.
I looked up apis and found this:
func setMinimumBackgroundFetchInterval(_ minimumBackgroundFetchInterval: NSTimeInterval)
And there is a tip for this:
The minimum number of seconds that must elapse before another
background fetch can be initiated. This value is advisory only and
does not indicate the exact amount of time expected between fetch
operations.
So I think you'd better not depend on that time interval.
There's this text Last seen: field in my application that shows for how long the current user is logged on the system (e.g. 5 seconds ago, 4 hours ago, 3 days ago, etc.). Now for me to do this, I need to determine either:
the time Apache Shiro performs the login; or
the time the current Grails Session has been created.
Then subtract it to the current time. But how can I access the creation time of either of the two? Or are there any better ways to achieve this not using the mentioned above?
In your controller action you can write like this:
class MyController {
// Considering this action is secured for logged in user only
def foo() {
long currentMillis = new Date().getTime()
long sessionCreationMillis = session.getCreationTime()
long loggedInFor = currentMillis - sessionCreationMillis
println "User has been logged in for $loggedInFor miliseconds"
}
}
Now, you got how long the user has been logged in (in milliseconds). Further, you can use the TimeUnit library to convert your milliseconds to other values.
Or, you can also use any Javascript library like this if you are planning to do it on client side.
I have no idea about Apache Shiro but I can tell you how to get the session creation time.
It's pretty simple actually, there is a method called getCreationTime() in HttpSession. Here is the doc
You can invoke this method on the session attribute available in controllers. This will return the time in milliseconds as long.
I'm building a messaging application. I update the badge count in the database via a sqlite trigger whenever any operation like insert/delete/read message happens.
Currently, though the value update in the DB happens asynchronously, I have no way to get notified about when the value changes in my application and hence am polling periodically.
Is there some way to setup an observer on a database value/publish some notification when a given value changes?
I know that I can do this easily by first updating the badge count in an in-memory property and then persisting the changes to the DB; but I am not very inclined to do this, since there are too many entry points for this value to change, and I don't want to add a SET property everywhere.
One possible option would be to define a trigger that is only called when this specific value in the database is updated. The trigger should then make a call to a user defined function you create in your app. You use the sqlite3_create_function function to add your own function to SQLite. Your trigger would like something like:
CREATE TRIGGER some_trigger_name
AFTER UPDATE OF some_column ON some_table
FOR EACH ROW BEGIN
SELECT my_custom_fuction();
END;
If needed, you can pass 1 or more arguments to your function.
Though that this might not be an option for you, Core Data does this well.
I want to know how to delete a single occurrence of recurring calendar event programmatically.
Using eventList.removeEvent(event) deletes the whole series from the calendar.
I have also tried getting enumeration from eventList.items(BlackberryEventList.OCCURRING, startDate, endDate, true) and then deleting the event whose start date and end date is matched but still it deletes the whole series. According to the api this function should return me the first instance of recurring event when I specify true in the last parameter.
Instead of removing event try to update repeat rule of the particular event.
Take a look at the following methods/classes:
setRepeat() method of Event class
RepeatRule class
addExceptDate() method of RepeatRule class