-2

I am new to windows mobile development. how can I access the hardware keys like volume down,volume up, power button by programmatic in c#.

2 Answers2

1

In Windows Phone 8.1 you have a class HardwareButtons which contains 4 events:

  1. BackPressed
  2. CameraHalfPressed
  3. CameraPressed
  4. CameraReleased

If you want use this in WIndows 10, you need add extension library

enter image description here

and get API for Windows Phone 8.1

if (Windows.Foundation.Metadata.ApiInformation.IsTypePresent("Windows.Phone.UI.Input.HardwareButtons"))
    Windows.Phone.UI.Input.HardwareButtons.BackPressed += HardwareButtons_BackPressed;
Andrii Krupka
  • 4,276
  • 3
  • 20
  • 41
0

As far as I known if you are an OEM, then the OEM has the special permissions to access these hardware button like the volume/power button, for more information, please try to refer to this article. But if you are an ordinary developers, I think it is not possible to access these hardware button like the volume/power button, in my mind these volume/power hardware button should be accessed/controled by the user not by the app.