Windows phone 8.1 使用LaunchUriAsync时未触发导航事件(WP 8.1)

Windows phone 8.1 使用LaunchUriAsync时未触发导航事件(WP 8.1),windows-phone-8.1,c++-cx,Windows Phone 8.1,C++ Cx,由于无法通过编程方式激活蓝牙,因此我会提示用户自行激活,并使用此方法打开所需的设置页面: auto uri = ref new Windows::Foundation::Uri("ms-settings-bluetooth:"); concurrency::create_task(Windows::System::Launcher::LaunchUriAsync(uri)).then([](bool success) { if (success)

由于无法通过编程方式激活蓝牙,因此我会提示用户自行激活,并使用此方法打开所需的设置页面:

auto uri = ref new Windows::Foundation::Uri("ms-settings-bluetooth:");

    concurrency::create_task(Windows::System::Launcher::LaunchUriAsync(uri)).then([](bool success)
    {
        if (success)
        {
            //URI launched
            OutputDebugString(L"Successfully launched settings from URI.\n");
        }
        else
        {
            ...
        }
    });
但是,我需要知道用户何时返回我的应用程序,以便检查蓝牙是否已激活,但Launchurisync不会触发任何导航事件,如OnNavigatedTo。等待该任务也不起作用(在我的情况下也没有意义,因为设置一显示就完成了)

那么,是否有可能检测到用户何时真正回来?

我也有同样的问题。 当位置服务关闭时,我要求用户打开位置服务,应用程序打开位置设置

当用户从设置返回时,我希望应用程序加载基于位置的消息

我创建了一个变通方法,使用了一个运行1分钟的while循环(用户有1分钟时间打开位置服务)

这是我的C代码#

wait Launcher.launchurisync(新Uri(“ms设置位置”);
bool-keepRunning=true;
int timesOfRunning=0;
同时(继续修剪)
{
运行时间++;
if(运行时间<21)
{
等待任务延迟(时间跨度从秒(3));
GeoLocationHelper geoLocation=新的GeoLocationHelper();
if(geoLocation.IsLocationServiceEnabled)
{
保持修剪=错误;
等待刷新消息();
}
}
其他的
保持修剪=错误;
}

LaunchUriAsync应触发OnNavigatedFrom事件。当用户返回时,您应该得到一个OnNavigatedTo@robwirving在WP8.1 RT中,您将不会获得
on导航到
(恢复后)-它仅在您导航到某个页面(
navigate()
)时才会触发。我也考虑过这一点,但在这种情况下它并没有真正帮助我。无论如何,我已经解决了这个问题,捕获了一个异常,如果用户试图启动蓝牙连接,就会触发该异常,正如针对Windows Phone的MSDN Bluetooth文档中所建议的那样。
await Launcher.LaunchUriAsync(new Uri("ms-settings-location:"));

bool keepRunning = true;
int timesOfRunning = 0;
while (keepRunning)
{
    timesOfRunning++;
    if (timesOfRunning < 21)
    {
        await Task.Delay(TimeSpan.FromSeconds(3));
        GeoLocationHelper geoLocation = new GeoLocationHelper();
        if (geoLocation.IsLocationServiceEnabled)
        {
            keepRunning = false;
            await RefreshMessages();
        }
    }
    else
        keepRunning = false;
}