{"id":3329,"date":"2023-11-22T00:28:29","date_gmt":"2023-11-22T00:28:29","guid":{"rendered":"http:\/\/putridparrot.com\/blog\/?p=3329"},"modified":"2023-11-22T00:28:29","modified_gmt":"2023-11-22T00:28:29","slug":"is-your-universal-windows-application-running-on-a-device-which-supports-this-hardware","status":"publish","type":"post","link":"https:\/\/putridparrot.com\/blog\/is-your-universal-windows-application-running-on-a-device-which-supports-this-hardware\/","title":{"rendered":"Is your Universal Windows application running on a device which supports this hardware ?"},"content":{"rendered":"<p>Just going through some old draft posts and found this one, which might be of use to somebody. Let&#8217;s call it a Quick Post as there&#8217;s not too much substance&#8230;<\/p>\n<p>When writing a Universal Windows application we&#8217;re basically trying to write code that will work on multiple devices. But different devices have different capabilities. For example a mobile phone has a back button, so we might want to handle the back button BackPressed event in some way, but this event is not available when the application is run on a desktop machine.<\/p>\n<p>Obviously it&#8217;d be no good using #define to enable\/disable code as we want the application&#8217;s code to be universal and run &#8220;as-is&#8221; on multiple devices. So we need a method call at runtime to tell us whether the device supports the BackButton. Or more specifically whether it supports the HardwareButtons input mechanism.<\/p>\n<p>So to check whether we can hook up code to the BackPressed event we might code the following<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\nif(ApiInformation.IsTypePresent(&quot;Windows.Phone.UI.Input.HardwareButtons&quot;))\r\n{\r\n   HardwareButtons.BackPressed += HandleBackPressed;\r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Just going through some old draft posts and found this one, which might be of use to somebody. Let&#8217;s call it a Quick Post as there&#8217;s not too much substance&#8230; When writing a Universal Windows application we&#8217;re basically trying to write code that will work on multiple devices. But different devices have different capabilities. For [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[107,13,20],"tags":[],"class_list":["post-3329","post","type-post","status-publish","format-standard","hentry","category-windows-10","category-wpf","category-xaml"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/3329","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/comments?post=3329"}],"version-history":[{"count":3,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/3329\/revisions"}],"predecessor-version":[{"id":10183,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/posts\/3329\/revisions\/10183"}],"wp:attachment":[{"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/media?parent=3329"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/categories?post=3329"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/putridparrot.com\/blog\/wp-json\/wp\/v2\/tags?post=3329"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}