在应用程序中更改设置时更改系统设置
Change the system settings on the change of settings in the application
我有一个显示电池状态的 UWP 应用程序。在应用程序中更改省电模式需要反映在系统设置中。
在 UWP 中可以吗?
Is it possible in UWP?
不,这在 UWP 中是不可能的。我们无法仅在 UWP 应用程序中以编程方式更改系统设置。正如@lindexi 所说,实现您想要的目标的正确方法是启动 Settings 应用程序,然后让用户更改节电设置。
要启动省电设置页面,我们可以使用 "ms-settings:batterysaver" URI,如下所示:
bool result = await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-settings:batterysaver"));
更多信息,请参阅Launch the Windows Settings app。
之后,我们可以使用PowerManager.EnergySaverStatus 属性 来检查用户是否启用了节电模式。
我有一个显示电池状态的 UWP 应用程序。在应用程序中更改省电模式需要反映在系统设置中。
在 UWP 中可以吗?
Is it possible in UWP?
不,这在 UWP 中是不可能的。我们无法仅在 UWP 应用程序中以编程方式更改系统设置。正如@lindexi 所说,实现您想要的目标的正确方法是启动 Settings 应用程序,然后让用户更改节电设置。
要启动省电设置页面,我们可以使用 "ms-settings:batterysaver" URI,如下所示:
bool result = await Windows.System.Launcher.LaunchUriAsync(new Uri("ms-settings:batterysaver"));
更多信息,请参阅Launch the Windows Settings app。
之后,我们可以使用PowerManager.EnergySaverStatus 属性 来检查用户是否启用了节电模式。