Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to start background task at boot - Windows Store app

My tablet runs Windows 8.1 pro.

It has a background task which is triggered by a Time Trigger every 15'. It works, fair enough.

The problem is that I need to auto-launch my background task at every single boot (start app) of my device.

I registered my bg by this code:

       builder.Name = "bikePositionUpdate";
        builder.TaskEntryPoint = "BackgroundTaskGps.BikeGPSPositionUpdateBackgroundTask";
        builder.SetTrigger(new TimeTrigger(15, false)); // 

        // adding condition
        SystemCondition internetCondition = new SystemCondition(SystemConditionType.InternetAvailable);
        SystemCondition userPresentCondition = new SystemCondition(SystemConditionType.UserPresent); 

        builder.AddCondition(internetCondition);
        builder.AddCondition(userPresentCondition);
        BackgroundTaskRegistration taskRegistration = builder.Register();

my app has lock screen access

         await BackgroundExecutionManager.RequestAccessAsync();

How can I achieve this? Am I missing something?

like image 288
eeadev Avatar asked Aug 26 '15 14:08

eeadev


People also ask

How do I start an app in the background in Windows?

Select Start , then select Settings > Privacy > Background apps. Under Background Apps, make sure Let apps run in the background is turned On. Under Choose which apps can run in the background, turn individual apps and services settings On or Off.

How do you see what's running in the background Windows 10?

You can access the Task Manager by pressing the Ctrl + Alt + Del shortcut keys on your keyboard, then select Task Manager. You can also right-click with your mouse on the Windows Taskbar and select Task Manager.


2 Answers

You have to add the SystemConditionType.SessionConnected condition, this condition happen every time the user log on to Windows.

An app must be placed on the lock screen before it can successfully register background tasks using this trigger type.

Edit:

On this url you can find the official documentation about what you need, and how to use it:

https://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh977056.aspx

https://msdn.microsoft.com/en-us/library/windows/apps/xaml/windows.applicationmodel.background.systemtriggertype.aspx

like image 54
frenk91 Avatar answered Sep 30 '22 19:09

frenk91


I think you should add SystemConditionType.SessionConnected condition,where this condition will check every time theuser log on to Windows
like image 31
Jinto John Avatar answered Sep 30 '22 20:09

Jinto John