Silverlight for Windows Phone Programming Tip #6

11 Comments February 11, 2011

Recently I have heard of a couple of cases in which apps submitted to the Windows Phone Marketplace were rejected because they continued running when an incoming phone call arrived. While the Windows Phone 7 Application Certification Requirements don’t specifically state than an application must pause when a call arrives, it seems that certain actions do trigger increased scrutiny from the certification folks. In one case, the app was rejected because it used the phone’s vibration controller and didn’t stop the vibration when the phone rang.

There is no specific API in Silverlight for Windows Phone for detecting incoming phone calls, but there is a pair of events in the PhoneApplicationFrame class named Obscured and Unobscured. Many developers mistakenly assume that these events are only raised when the screen locks and unlocks. In fact, they’re raised anytime your application is obscured by a piece of the UI shell, including when the phone receives a call. Regardless of whether your app is designed to run under a locked screen, you can use these events to make sure that your app behaves properly when it’s interrupted by a phone call or anything else that brings the shell to the foreground.

A page can register handlers for Obscured and Unobscured events through the application’s RootFrame property. The following code snippet registers handlers for both events and calls VibrateController.Stop when the application is obscured by the shell:


(Application.Current as App).RootFrame.Obscured += OnObscured;

(Application.Current as App).RootFrame.Unobscured += OnUnobscured;




void OnObscured(object sender, ObscuredEventArgs e)





void OnUnobscured(object sender, EventArgs e)




The Windows Phone 7 Application Certification Requirements do state that an application “must not delay or prevent the ability of the user to initiate a call, answer an incoming call, or end a call.” If you write an app whose actions could violate that dictum, use Obscured and Unobscured events to devise a fix.


  • Gravatar Image
    Twitter Trackbacks for Jeff Prosise's Blog : Silverlight for Windows Phone Programming Tip #6 [] on February 11, 2011 11:34 AM

    PingBack from

  • Gravatar Image
    KRK February 11, 2011 4:18 PM

    Excellent Tip Jeff !!!

    Thanks for saving my time.

    Regards & Cheers,


  • Gravatar Image
    tsunami May 17, 2011 1:31 AM

    Thanks for the tip, but actually i need to simulate an incoming call as my application will automatically send sms replies to it and it seems that there is no way to do it on the emulator..

  • Gravatar Image
    Roshan Khan June 2, 2011 9:06 AM

    Thank you Thank you Thank you so much.
    Mine is one of those apps which was rejected for the reason that vibration didnot stop on an incoming call and i had tried so many things.
    I shall try this and lets hope it works

  • Gravatar Image
    Steve June 9, 2011 4:32 PM

    Jeff, thanks for the info, however i get the following when trying to add the code to my MainPage.xaml.cs MainPage class...

    System.Windows.Application.Current is a property but is used as a type.

  • Gravatar Image
    Steve June 9, 2011 4:59 PM

    Problem sorted now. Thanks a million Jeff. Where would Microsoft be without you ;-)

  • Gravatar Image
    Steve June 21, 2011 4:39 PM

    unfortunately although the code now compiles, this is not stopping the vibration controller. My app has been rejected twice now as the incoming phone call does not stop the vibration controller even when i implement the OnObscured event and call VibrateController.Default.Stop.

  • Gravatar Image
    Om December 24, 2011 12:36 AM

    I used this tip in following scenario.
    I have to stop my animations and reset some element properties like opacity=0, in the OnNavigatedFrom. Interesting OnNavigatedFrom is also called upon going into Obscured mode. So upon resuming, I was losing my animation and the elemets were set to opacity=0 making them invisible.

    So I used the two events to solve those issues.

    Thanks for blogging this.

  • Gravatar Image
    Classifieds php February 3, 2012 4:20 AM

    Thanks for the tip about Silverlight for Windows Phone Programming. Its really very beneficial for me in my work.

  • Gravatar Image
    classified scripts February 15, 2012 4:40 AM

    Pretty good post. I just stumbled upon your blog and wanted to say that I have really enjoyed reading your blog posts. Any way I will be subscribing to your feed and I hope you post again soon. Thanks!

  • Gravatar Image
    NZ Community Blog February 25, 2012 3:00 AM

    Hi Guys, We have started on the road this week hitting most of the North Island – make sure you attend

Have a Comment?