{"id":47,"date":"2010-10-07T16:53:07","date_gmt":"2010-10-07T15:53:07","guid":{"rendered":"http:\/\/ree7.fr\/blog\/?p=47"},"modified":"2022-08-08T06:47:42","modified_gmt":"2022-08-08T05:47:42","slug":"desactiver-le-lock-screen-sous-windows-phone-7","status":"publish","type":"post","link":"http:\/\/www.ree7.fr\/blog\/2010\/10\/desactiver-le-lock-screen-sous-windows-phone-7\/","title":{"rendered":"D\u00e9sactiver le lock screen sous Windows Phone 7"},"content":{"rendered":"<p><img loading=\"lazy\" class=\"aligncenter size-full wp-image-48\" title=\"Lockscreen Windows Phone 7\" src=\"http:\/\/ree7.fr\/blog\/wp-content\/uploads\/2010\/10\/IMAG0030.jpg\" alt=\"Lockscreen Windows Phone 7\" width=\"430\" height=\"640\" srcset=\"http:\/\/www.ree7.fr\/blog\/wp-content\/uploads\/2010\/10\/IMAG0030.jpg 430w, http:\/\/www.ree7.fr\/blog\/wp-content\/uploads\/2010\/10\/IMAG0030-201x300.jpg 201w\" sizes=\"(max-width: 430px) 100vw, 430px\" \/><br \/>\nWindows Phone\u00a07 n&rsquo;est pas multi-t\u00e2che (du moins pour les d\u00e9veloppeurs tiers), \u00e7a vous le saviez d\u00e9j\u00e0. Mais disons que vous souhaitez d\u00e9velopper une application qui occupe le t\u00e9l\u00e9phone un long moment sans interaction de l&rsquo;utilisateur avec l&rsquo;\u00e9cran (ce qui aurait pu \u00eatre une t\u00e2che de fond sous WM6.5 ou Android mais je vais m&rsquo;\u00e9loigner de mon sujet&#8230;) : vous allez rencontrer un probl\u00e8me, c&rsquo;est que le t\u00e9l\u00e9phone va se mettre en veille et tombstonner votre application.<\/p>\n<p>Cela peut \u00eatre fort g\u00eanant si vous d\u00e9veloppez une application de musique (radio), ou vid\u00e9o (bien que si vous utilisez MediaElement, les choses ont \u00e9t\u00e9 bien faites et la lecture d&rsquo;un m\u00e9dia inhibe le lockscreen), ou encore une application de tracking GPS (<strong>#ridetracker<\/strong><em>, projet WP7 \u00e0 venir sur ce blog<\/em>).<\/p>\n<p>Sachez que vous pouvez inhiber la veille du t\u00e9l\u00e9phone de deux fa\u00e7ons :<\/p>\n<ul>\n<li>Microsoft.Phone.Shell.PhoneApplicationService.Current.ApplicationIdleDetectionMode = Microsoft.Phone.Shell.IdleDetectionMode.Disabled<br \/>\nPermet \u00e0 votre application de ne pas se faire tombstonner quand le t\u00e9l\u00e9phone se met en veille, en clair votre application tourne derri\u00e8re le lockscreen. C&rsquo;est le comportement le plus proche d&rsquo;un thread d&rsquo;arri\u00e8re plan.<\/li>\n<li>Microsoft.Phone.Shell.PhoneApplicationService.Current.UserIdleDetectionMode = Microsoft.Phone.Shell.IdleDetectionMode.Disabled<br \/>\nPermet de d\u00e9sactiver purement et simplement le lockscreen !<\/li>\n<\/ul>\n<p>Tant que j&rsquo;y suis, PhoneApplicationService contient une autre propri\u00e9t\u00e9 int\u00e9ressante : <em>Microsoft.Phone.Shell.PhoneApplicationService.Current.StartupMode<\/em>, qui permet de savoir si vous \u00eates dans une nouvelle instance de l&rsquo;application ou bien si vous \u00eates r\u00e9ssucit\u00e9 d&rsquo;un \u00e9tat tombstonn\u00e9.<\/p>\n<p><em>[English version below]<\/em><\/p>\n<p><!--more--><\/p>\n<p>English version : <strong>Disable Windows Phone 7&rsquo;s lock screen<\/strong><\/p>\n<p><strong><span style=\"font-weight: normal;\"><br \/>\nWindows Phone 7 does not allows multitasking for 3rd-party developpers, but I think you already know about that. But say you&rsquo;re looking to develop an app that keeps the phone busy for a while, without requesting any user interaction (what could have been a background thread on WM6.5 or Android, but that&rsquo;s another topic&#8230;) : you&rsquo;re going to have a problem, within some time the phone will go to standby mode, and your app is going to be tombstonned.<\/span><\/strong><\/p>\n<p>That could be a problem if you&rsquo;re developping a music\/radio\/video app (even though the fact that you should use a MediaElement, and it&rsquo;s smart enough to disable to lockscreen while a media is played), or a GPS tracking app (#ridetracker, more to come soon on this blog).<\/p>\n<p>Well, you can solve this problem by using one of the following<\/p>\n<ul>\n<li><strong><em>Microsoft.Phone.Shell.PhoneApplicationService.Current.ApplicationIdleDetectionMode = Microsoft.Phone.Shell.IdleDetectionMode.Disabled<\/em><\/strong><br \/>\nThe shell won&rsquo;t kill your process while the lockscreen is on. That&rsquo;s the closest behavior to a background thread.<\/li>\n<li><strong><em>Microsoft.Phone.Shell.PhoneApplicationService.Current.UserIdleDetectionMode = Microsoft.Phone.Shell.IdleDetectionMode.Disabled<\/em><\/strong><br \/>\nThis one will simply disable the lockscreen !<\/li>\n<\/ul>\n<p>And while I&rsquo;m at it, there&rsquo;s another interesting item in PhoneApplicationService :\u00a0<em>Microsoft.Phone.Shell.PhoneApplicationService.Current.StartupMode<\/em> which value tells your application is a fresh instance or bought back to life from tombstonning.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Windows Phone\u00a07 n&rsquo;est pas multi-t\u00e2che (du moins pour les d\u00e9veloppeurs tiers), \u00e7a vous le saviez d\u00e9j\u00e0. Mais disons que vous souhaitez d\u00e9velopper une application qui occupe le t\u00e9l\u00e9phone un long moment sans interaction de l&rsquo;utilisateur avec l&rsquo;\u00e9cran (ce qui aurait pu \u00eatre une t\u00e2che de fond sous WM6.5 ou Android mais je vais m&rsquo;\u00e9loigner de [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","enabled":false}}},"categories":[7],"tags":[28,52,27,20],"jetpack_publicize_connections":[],"aioseo_notices":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p19lzH-L","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"http:\/\/www.ree7.fr\/blog\/wp-json\/wp\/v2\/posts\/47"}],"collection":[{"href":"http:\/\/www.ree7.fr\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.ree7.fr\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.ree7.fr\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.ree7.fr\/blog\/wp-json\/wp\/v2\/comments?post=47"}],"version-history":[{"count":1,"href":"http:\/\/www.ree7.fr\/blog\/wp-json\/wp\/v2\/posts\/47\/revisions"}],"predecessor-version":[{"id":597,"href":"http:\/\/www.ree7.fr\/blog\/wp-json\/wp\/v2\/posts\/47\/revisions\/597"}],"wp:attachment":[{"href":"http:\/\/www.ree7.fr\/blog\/wp-json\/wp\/v2\/media?parent=47"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.ree7.fr\/blog\/wp-json\/wp\/v2\/categories?post=47"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.ree7.fr\/blog\/wp-json\/wp\/v2\/tags?post=47"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}