Background Task in Windows phone is not working - windows-phone-7

I am Working on Background task in Windows phone application but it is not calling .When do launch for test it is working but in real scenario app is not calling background services.

Do you use ScheduledActionService.LaunchForTest? This function is not supposed to work on a real phone. You have to deal with the fact that instead of running every 1-2 minutes your background task will be launched once every 30 minutes or so as stated in Constraints For Periodic Agents section.
If everything is fine in your simulator, you have to cross your fingers and keep waiting for a half of hour or so just to test that you are actually launched. Yes, it's a pain to debug, but we have no other official way.
You may also try adjusting local time on device. Sometimes going half an hour into the future helps trigger background agent immediately.

Related

Running settimeout in the background

Why doesn't settimeout/debounceTime work when the app is minimized? Events are still being triggered, but I was wondering if there is a way to make timers work while the app is backgrounded.
As soon user leaves your app, the system will stop it from running to reduce battery usage.
If you like your app to execute in background, you must use the appropriate options in the desired platform (Background Task / Fetch in iOS | Background services in Android).

Windows phone 8: Live tile updates in the emulator but not when downloaded from the maket

I have made an app with live tile for windows phone 8. The tile is programmed to refresh every 30 seconds. When the run the app in the emulator or when I deploy the app in my cell (Lumia 920) the tile works fine. But surprisingly when I downloaded the same app from the market and run it on the same device the tile doesn't update.
I did quite a bit of research on this problem and found that a similar problem is observed by many other people which can be found here.
Kindly tell me what is going wrong.
Extra Info : I have tried resizing the tile, pin and unpin the tile and hard reset. I have also tried changing the refresh period (initially the refresh period was 5 seconds). I have also checked that the background task is allowed for the app.
Thanks,
Apurva Pathak
Background agents have certain limitations, as listed below.
Background tasks can minimally be run every 30 minutes. There is a debug-only API to run them more regularly, but this is not available for released apps.
Some low power devices do not support background agents
Background tasks are limited by number on each device and can be enabled or disabled from application settings.
They do not work when power saver mode is activated.
As Mahantesh correctly pointed out your tiles work when you deploy the application because the ScheduledActionService.LaunchForTest() is allowed to run for a 60 seconds period for debugging and testing purposes ONLY.
Therefore this method cannot be called and it wont work with a time limit less than 30 minutes if the application is published to the market and users download it from there.

GPS based application not running under lock screen in windows phone

I have developed a windows phone application and it works fine when it is open and running actively.
It tracks the user movements on the map and shows the position moves with push pins.
Now I want to ensure that the same application runs even the phone is locked when this app was open.
I have added the below code for it to work under lock screen. After this when I verified the app I realized it is not running when the application is locked.
Is there any other change I need to make to get this work under lock screen.Any help would be greatly appreciated.
private void initiliazesettings()
{
PhoneApplicationService.Current.UserIdleDetectionMode =
IdleDetectionMode.Disabled;
}
To have your app running under lock screen on Windows Phone 7.0/7.1/8.0, you need to set ApplicationIdleDetectionMode, not UserIdleDetectionMode. See details here.
Supossing you placed the method in the right place, that code only keeps the screen on, but doesn't make your app run in background when the lock screen is activated. Windows Phone 7 apps cannot run in background, they get tombstoned.
For Windows Phone 8 this is possible - see the sample here from MSDN.
However for Windows Phone 7/7.1 you can't do this.
You can prevent the screen from locking due to the user not interacting with it (as your code shows). However if you manually lock the screen the app will still be made dormant or tombstoned and your location code won't run.
Your only other option is to use a scheduled background task to read the location of the phone, but bear in mind that this is far from real time data (it is a cached location and you only run once every 30 minutes in the best case scenario).

NSTimer in Cocoa (MAC) app

I am working on a timer application where i have used 5-6 timers running at one time, I need all the timers running at the same time. For ex. calculating a time, updating the UI etc.
But this is hangs my app, After some time, its started not responding.
Then i quit the app and re-launch but this time i didn't start the timer (Only one timer is running) and i found that application is fine this time.
I think the issue is due to usage of multiple timers at the same time as these timers are updating the UI frequently after every seconds. I need to updated my label with the updated time, but how i could do this without using an NSTimer. If NSThread is an option then please give me an example to achieve this.

Debugging mobile software in the VS device emulator - app switching to background

I have this issue when debugging mobile apps on the emulator. When I press F5, the build starts, then the deploy, then the app pops up in the emulator.
Because this takes a minute or 2, I am checking my SO score and maybe ask a question while I wait, and the emulator is in the background. When I finally switch back to the emulator, it shows the start page, not my app.
I figured out that by pressing the back button I can bring the debugged application to the foreground, but still, I don't know what is pushing it into the background to begin with. Has anybody noticed this, and found a way to prevent it?
The default behavior in WinMo is that if the device has no activity for a certain period of time (set in Settings->Today->Items->Today Timeout), the Today screen will come to the fore. Check to see if that's what's happening (though I think the smallest interval is still larger than a couple minutes).

Resources