Skip to content

How to run your WP7 app even under lock screen

June 26, 2011

A common thing which I have found out on the application that I am working on is that  when the lock screen appears or an incoming phone call occurs, you application immediately closes without warning which is very cumbersome.

There is some scrutiny over when applications that were submitted were rejected because it continued running when the phone call arrived as some people think your application should do the tasks at hand when you are currently using it on the phone, but Microsofot believes the basic functionality of the phone in this case should be intervened, which is why most applications get rejected.

There are solutions to overcome this, and are the following steps: –

1.Set PhoneApplicationService.Current.ApplicationIdleDetectionMode = IdleDetectionMode.Disabled;
2.Handle the  Application’s RootFrame  Obscured and Unobscured events.  So you know when the lockscreen comes on.

The RootFrame property does this via the handlers for both events and calls VibrateController.Stop or other similar events.

(Application.Current asApp).RootFrame.Obscured += OnObscured;

(Application.Current asApp).RootFrame.Unobscured += OnUnobscured;

void OnObscured(object sender, ObscuredEventArgs e)





void OnUnobscured(object sender, EventArgs e)



Obscured will be called when your app is getting locked hence you allow as much as you can to reduce CPU or it’s battery consumption like stopping  animations, or analyinglocation changes. 
Unobscured of course gets called when screens us getting unlocked. This is when the user comes back, and you pick where they left-off before phone went under the lock.
3.[Optional] You should Prompting the userthat its running under lock.
4.[Optional] You should expose your application configuration settings to allow user to change their mind or simply want to disable it and conserve power.
5.If your application sets ApplicationDetectionMode to IdleDetectionMode.Disabled,  it can not change that back to IdleDetecionMode.Enabled until application is either launched again, or that it is restarted.


From → Uncategorized

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: