I wish to schedule notifications every day at 7:30am, even if the phone has been rebooted or is locked.
AlarmManager can do the trick, but it doesn't work if the application has been dismissed/killed.
FirebaseJobDispatcher works too, but it doesn't fire exactly at the time you want. It fires roughly at the time you want it to fire.
Both approaches have drawbacks which I can't make do with.
How can I achieve this goal but have the benefits of both the approaches above? I need the notification showing regardless of if the application has been dismissed and I need it to be accurately fired at 7:30.
Related
I'm making a Clock app in swift for OS X. I have a Timer in my Clock app that works kinda like the one in iOS. My problem is whenever I put my app into the background or minimize it the application kinda freezes or stops counting after being in the background for a minute or so. It starts working right where it left off when I bring it into the foreground. Is there anyway I can make my application run in the background? I've looked and haven't found anything that works.
Thanks to anyone who can help.
Are you relying on the timer to "count" the seconds? You should only use the timer to provoke an update of the display. When the timer fires, you should check the actual time and calculate what should be displayed based on that time, not how many times your timer has fired. It should never be the case that your app "starts working right where it left off" (if, by that, you mean that it shows the same time as when it was backgrounded and starts counting up from there again).
What's probably happening is that your app is being put into App Nap. Also see the Energy Efficiency Guide for Mac Apps.
I figured I'd ask here and see if anyone could offer anything, you guys are the faster answerers of anything. By default, when you hide a calendar in iCal (Snow Leopard) (clicking the checkbox), by default, every event is still armed. Like the alarms for hidden events will still activate at those times. I'd like them to turn off as long as the calendar is hidden. Is there maybe an applescript way to accomplish this?
Right now I'm trying a new anti-lazy workflow where I schedule tasks for myself ahead of time and force myself to switch to them (instead of saying "i'll do it later") by having the alert for each event be to activate a program that locks me out of my computer for 3 mins (Time Out). So far it's working well but being able to switch alarms on and off that quickly would really help.
Thanks!
Edit: I know you can right click and go to a dialog that turns off all alarms for that calendar, but it's so easy to forget to do that.
EditEdit: While we're at it, is there a way to move multiple events at once? You'd think this would be a given, but instead it just makes one new event where you dragged.
I'm developing my first Windows Phone 7 app. I don't yet have access to an actual device, so I am relying on the emulator that ships with the SDK.
In my app, I use the EmailComposeTask and SmsComposeTask where required. When debugging my app in the emulator, I click a button which runs one of these tasks, and it works. But when I then push the back button to get out of the task and back to my app, the app state is lost - it's as if I am launching it fresh all over again.
But, where it gets weird, is that on occasion this doesn't happen. I have gone back from one of the Tasks more than once to find my app state exactly how I left it.
And so, my questions:
Is this just a bug with the emulator?
If not, why is not consistent, and how should I be "saving" my app state prior to call the Email or SMS task?
Thanks.
Your page is being tombstoned which is why it seems like your application has restarted. This basically means that your app is still stored on the stack, ready to be called, but pages state and other data information is lost. To fix this, you need to handle the serialization of any data you want to keep.
For transient data, like page state things (e.g. textboxes, checkbox etc..), you can use PhoneApplicationPage.State. I believe the limit is 2mb. If you need to store more, you should store it in Isolated Storage (unlikely, unless you need to save an image). You can read about the process here. To understand the process of Tombstoning, you should read this MSDN page. To save time, you can use Tombstone Helper which handles all the lower level storage details for you, but it's a good idea to understand the process of Tombstoning anyway so you know what's going on.
The reason your app doesn't always get tombstoned is because EmailComposeTask doesn't cause a tombstone straight away. From this MSDN blog post:
Below is the list of native
experiences that, when invoked, do not
trigger an automatic tombstone in the
calling application:
PhotoChooserTask
CameraCaptureTask
MediaPlayerLauncher
EmailAddressChooserTask
PhoneNumberChooserTask
There are three scenarios in which an
application in the background will
immediately be tombstoned:
User forward navigates away from an application [for example, user
presses the Start key]
Application invokes launchers or choosers not listed above
System requires more resources to carry out a foreground activity
As you can see, that's not to say EmailComposeTask will never cause a tombstone, so you should still handle it, but it explains why your page state is sometimes kept automatically.
I want to check for changes in the aplication state every time interval, and if it has changed, to open a window, and give the user 10 seconds to press on the window, if he does press on the window, then to allow him to navigate freely in the window, and if he doesn't press, to return back to the window before. I thought to implement it with a thread running in the background and waking up every time interval I want. Maybe there is a better way?
This strikes me as a scenario with lots of potential issues.
How do you stop the "window" appearing at an inconvenient time to the user? (e.g. when they were just about to tap on som.ething)
Why not just raise the notification when the state actually changes? This way you wouldn't need to poll.
What is the "Window" you are displaying? How does it differ from the page it is replacing? Is this a popup or are you actually navigating to a different page?
What is the state that's changing? How is it changing without user interaction?
Can't you notify the user of the state change without a potentially intrusive display of a new "window"?
I agree with #matt-lacey, this could be dangerous and might result in a bad user experience.
With that said, this might work
Deployment.Current.Dispatcher.BeginInvoke(() =>
{
//navigation code here
});
I didn't know you could do a pop-up window, could you elaborate?
I've made a thread that is running at the background and making some work, if it decides that a change is necessary, I want to give the user a chance to react to it, or ignore it.
I'm pretty new to this, so if there is a better way than to navigate to a different page i would love to hear it.
Thanks.
It sounds to me like you want to notify the user that something has happened/changed and give them the option to do something about it, which is exactly what "toast" notifcations are all about. They pop up at the top of the screen to inform the user, and then the user can tap that toast to do something, e.g. when WiFi networks are available, you tap the toast to select an available network.
The Silverlight Windows Phone Toolkit includes the ToastRequestTrigger that you use to display toast notifications. The Windows Phone Developer Guide from the patterns & practices team gives examples of using the ToastRequestTrigger. You will need to implement the tap handling yourself in the toast content, but this should be simple enough.
If I wanted to ignore a touch event in UIKit on the iPhone I would simply do:
// Begin ignoring events
[[UIApplication sharedApplication] beginIgnoringInteractionEvents];
//Do my code
// Stop ignoring events
[[UIApplication sharedApplication] endIgnoringInteractionEvents];
This allows my code in between the "ignore" calls to operate without having to worry about user interaction changing any state of the application.
My question is, how can I do this if I am writing a Mac OS X app (AppKit vs. UIKit)? I basically want to "lock-out" the user during some operations (specifically, making network calls, and changing state quickly would queue up a ton of network calls that would quickly get in the way of each other).
Do I need to manage this manually with AppKit? I.e. put up a progress bar, and disable all UI Elements by hand?
On the desktop you really don't want to do such a thing. It only works on the iPhone because there is nothing else a user might reasonably want to do with your app at the time. On the desktop there are possibilities for multiple windows etc. and anytime your app is unresponsive is considered a bug.
So more directly: No, there is nothing like this. You have to achieve the same effect with a sheet/modal panel, but most of the time should design the UI such that it's not a problem anyhow.