Application deactivation in Windows Phone 7 - caused by user or system. How to distinguish?

372 views Asked by At

Is it possible to distinguish the cause of application deactivation?

Aplpication enters the deactivated state when users press back button or there is a call\SMS. My question is - how to distinguish the cause? It is important to prevent cheating etc.

I have time counter - it will be ok to freeze it when there's income call or SMS. In case of pressing back button it shouldn't be saved.

2

There are 2 answers

0
Emond On

If this is to prevent cheating in a game I wouldn't make make a distinction between 'back' and 'getting a call' because to the user that would be confusing and it would trigger others to cheat by having someone call them.

Just resume from the game's last save point or offer to try the level again.

1
Kevin Gosse On

Haven't tested it but it may work:

  • Handle the back button on your page, set a static flag to true, then proceed with the 'normal' back button behaviour
  • On each page, override OnNavigatedTo and set the flag to false

Now, when the Desactivated event is triggered, if the flag is set to true then you know the user has pressed the back button.