Is there something in Windows Phone similar to services in Android?
I already read the documentation on Background agents (Periodic agents) but they only perform some code once every 30 minutes.
I need to have a service running all the time..
Unfortunately, in 7.1 it is not possible. I hope in the next versions this will change.
Related
I am writing a UWP app that expect to have updated data from a remote, say a cloud service or a remote station or whatever.
So, I thought an obvious solution would be to write a service that will sync data periodically and UWP app will just show it. I started reading about it and ended up reading this MSDN article about Windows 10 AppService
https://learn.microsoft.com/en-us/windows/uwp/launch-resume/how-to-create-and-consume-an-app-service
But after reading the article, I stumble upon this portion as per screenshot below which basically tells that if my app is back-grounded (minimized or covered by another app), then the service will continue running for up to 30 seconds and then stop running. This means after 30 seconds, my background syncing will stop:
How can I make sure that my data is being refreshed when needed even though my app is not in the foreground?
Your background task can only run for 30 seconds for processing information but you can make it so your background task runs ever 15 minutes to check if new information is available using a Time Trigger.
If you want your application to check more frequently you will have to use a Toast Notification that comes from a server, such as Azure Mobile App Service, AWS Simple Notification Service, etc. or you can create your own service using the WNS(windows notification service).
Azure
https://azure.microsoft.com/en-us/services/app-service/mobile/
AWS
https://aws.amazon.com/sns/
I have just started using Win 8 Metro style Apps development.
Is there a way exist to track when the out going call is connected?
I want to alert the user (may be phone vibration), once connection is established.
Please give me some hint to accomplish the same.
Thanks in advance
If you are talking about simple phone calls, then no. All call-related activity is handled by the system, and your app has no control over it and therefore no need to be notified about it. If you initiate a call task from your app, the app is put into the background, and the system takes over to handle the call. This is the same behaviour as in previous Windows Phone versions.
I am writing update checker program in xcode, my program needs background process( it needs to be run in background), so is it possible in phonegap, and is there any phonegap plugin for background services? Thanks
iOS does not allow background task to run more than a specific time limit.
Similar Post:
iPhone background task stops running at some point
Explanation:
http://www.macworld.com/article/1164616/how_ios_multitasking_really_works.html
The reasonable solution would be to implement a push notification and send a notification whenever there is an update on server.
It is definitely possible to run some JS code in the background to be checking this (https://github.com/jocull/phonegap-backgroundjs).
It won't be possible to do it for more than 10 minutes in the background, though (Run app for more than 10 minutes in background)
So you'll need both a combination of the first plugin I mentioned and the PN service that dhaval is suggesting.
Cheers!
I have Android application where service running 24/7 Phone get's GPS position every 5 minutes and sends to server. This is requirement.
Can I write same service for iPhone? I'm not sure if it's possible.
Can I write same service for WP7? I think it wasn't possible to run service before. Did anything change in 7.5?
EDIT:
I'm not sure why somebody downvoted. This is concrete Yes/No question.
It is possible in WP7 with the introduction of background tasks in Mango. In fact, there is a built in mechanism for polling the GPS provided by the API that is more battery efficient.
Not sure if it goes down to 5 minutes, think it is something larger like 30 minutes. It is also not comparable to a Windows Service - so don't go fowards with that mind set. Background tasks are heavily constrained to keep the phone responsive for the user - to make use of them, you need to play nice with the requirements.
Background tasks introduction, it also talks about the GPS thing I mentioned. The entire series is well worth your bandwidth and time downloading and watching:
http://channel9.msdn.com/Series/Mango-Jump-Start/Mango-Jump-Start-06-Windows-Phone-Multi-tasking--Background-Tasks
Can't answer for iPhone.
It is also possible on ios4+ but it wont be time-triggered. Either you register for precise (gps) or vague location (wifi and wan location) which is available to get in background but it is not always possible to send that data to a server because after 10 minutes in background your app is not allowed to keep a network-connection alive. So you have to buffer that data and have to wait until the user launches your app.
The ios pushes notifications to your app depending on the needed accuracy and depending on a distance-filter
ios-apps do not differ between services and activities (like in android). it is all combined in one app.
There are "some limitations"(a lot) here too, but maybe Microsoft Push services works for you:
Push Notifications Overview for Windows Phone
Because polling is not a good practice for this, push works better in this cases.
In WP7 Mango you can't get a fresh location from a background agent. The following code will return the latest available location (up to 15 minutes old):
private GeoPosition<GeoCoordinate> GetCachedLocation()
{
GeoCoordinateWatcher geoWatcher;
geoWatcher = new GeoCoordinateWatcher(); //Start a new watcher with default level of accuracy
geoWatcher.Start();
//Get latest cached position
GeoPosition<GeoCoordinate> position = geoWatcher.Position;
geoWatcher.Stop();
return position;
}
As you can see, this uses GeoCoordinateWatcher. According to MSDN (http://msdn.microsoft.com/en-us/library/hh202962(v=vs.92).aspx):
This API, used for obtaining the geographic coordinates of the device,
is supported for use in background agents, but it uses a cached
location value instead of real-time data. The cached location value is
updated by the device every 15 minutes.
Other than that, I haven't been able to find much information. You could create a GeoCoordinateWatcher with a self-defined accuracy, but I haven't tested this. Perhaps it would return the latest available cached location that satisfies the accuracy requirement.
Ever since the first beta came out I’ve been trying to find out if “real” multitasking is possible — i.e. can you put a program in the background and have it hang on to a network connection indefinitely?
I’m thinking about IM or IRC apps, for example. I’ve compiled an app myself on iOS 4, and without changing a thing it appeared to stay running in the background, but for all I know it was just suspended to memory.
The docs say the best you can do is request up to 10 minutes, but in the developer presentation they showed off Skype sitting in the background and then notifying the user that a call was coming in. Does anyone know for sure how this all works?
It appears the answer is no. The API for Skype is a very special case, called the "voip" mode, and requires special behavior, such as marking the socket in use for VoIP.
You can receive alarm notifications in the background (such as time passed). The amount of time you are in the background running state is severely limited by the OS.
Android's background model is complete and in many ways much nicer.
Apple has a guide named "Supporting Multitasking In Your Applications" which you should be able to locate.
Apple's iOS 4 developer docs outline this all very clearly.
When your app is closed or switched away from, it is almost immediately "suspended", meaning the OS freezes the app's state. When the user switches back to your app, your code keeps running just where it kept off. You don't need to add any code to your app to do this, just compile it against OS 4.
The above is true in most cases. There are two reasons the "suspended" model may not apply:
1) If the device starts to run low on memory, the OS will start terminating suspended apps that haven't been switched to in a while, without warning. This is why it's in your best interest for your app to remember it's state as well, so if your app is terminated, then re-opened, the user doesn't really notice because it still returns to right where they left off.
2) Your app uses one of the "background" APIs. These are for audio playback, VoIP services, or location services. In this case, your app is allowed to continue running in the background but only has access to those APIs. Additionally, your app can designate certain long-running tasks as "background tasks" that need to be completed before the app is suspended or terminated, like uploading pictures to Flickr or rendering a video, etc.
The "background task" method doesn't cover pinging servers indefinitely, as there is a time limit for the task, after which it will be forcibly halted. Apps that need that sort of functionality are expected to implement push notifications, just as before.
That should clear this up. All in all I think it's a pretty elegant solution to multitasking on a mobile device.
iOS 4 applications can either be running or suspended. The operating system will try to keep as many requested applications as possible in memory, while all other applications are suspended.
Applications that run in the background can access features such as navigation, audio, and VOIP (but NOT instant messaging). So it looks like you might be out of luck.
-- PC World Multitasking on Apples iPhone 4
It is possible for apps to request background time. Read the docs. I would say it iOS is "controlled multitasking".
You can create a long running background task, I believe these can include networking features. Just have to set the background task flag on the work block.
https://developer.apple.com/iphone/library/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/BackgroundExecution/BackgroundExecution.html
the OS can limit exactly how much time you get though... it will tell you when your time is up giving you a chance to cleanup nicely.
iOS 4 has "real" multitasking to some extend. There are two things to consider:
The UI event loop is single tasking. So only the front app executes on the UI event loop. Not a big deal: detach your main code form the UI event loop (maybe you need to redesign your app).
The OS "may" terminate your app if some criteria are met (e.g. low memory).
Currently one of these criteria is that execution time is limited to 10 minutes (real time not cpu time). However I expect this to change and see better criteria for background app termination (I hope to).
Apart from this you can have timers (event loops) in background.
There is no real multitasking in iOS 4.2 even. because apps will only be allowed to finish the task related to states..for small interval of time and then it will be in suspended state.. If you will set background task for long interval of time then... it will behave unexpectedly like no method will be called when you will try to run the app from anywhere..
You may be interested in this blog post that outlines how "multitasking" works in systems such as iPhone OS 4 and Android.
in fact u can do this, although it's not allowed by Apple. u gotta set up a toolchain in ur mac and use some unofficial SDK...
check http://code.google.com/p/iphone-backgrounder/ for more information
You should use the Push Notifications framework for the feature set you are creating!