0

CameraCaptureTaskユーザーがLensPickerからアプリを選択した後、アプリが直接移動することになっているLensアプリケーション機能をテストしようとしています(メインページにビューファインダーがないため)。MainPage に戻るとCamerCaptureTask、画面にイメージを表示する completed イベントがあります。

アプリケーションが廃棄され、完了後に再起動される前にクリアできない値CameraCaptureTaskの結果に基づいてmy が繰り返し呼び出されるという、奇妙な繰り返しの状況で問題が発生しています。QueryStringCameraCaptureTask

LensExampleUriMapper.cs

private string tempUri;

public override Uri MapUri(Uri uri)
{
    tempUri = uri.ToString();

    // Look for a URI from the lens picker.
    if (tempUri.Contains("ViewfinderLaunch"))
    {
        // Launch as a lens, launch viewfinder screen.
        return new Uri("/MainPage.xaml?fromLensPicker=" + "fromLensPicker", UriKind.Relative);
    }

    // Otherwise perform normal launch.
    return uri;
}

MainPage.xaml.cs

protected override void OnNavigatedTo(NavigationEventArgs e)
{
    string fromLensPicker = null;
    if (NavigationContext.QueryString.TryGetValue("fromLensPicker", out fromLensPicker))
    {
        if (fromLensPicker == "fromLensPicker")
        {
            newButton_Click(null, null);  //click event that calls CameraCaptureTask
            fromLensPicker = null; //Temporarily nullifies value until MainPage is OnNavigatedTo after CameraCaptureTask completes
        }
    }
}

値をクリアして、アプリケーションが完了してアプリが続行された後にQueryString継続的に呼び出されないようにするにはどうすればよいですか?newButton_Click(null, null)CameraCaptureTask

4

2 に答える 2

0
string fromLensPicker = null;
if (NavigationContext.QueryString.TryGetValue("fromLensPicker", out fromLensPicker))
{
    if (fromLensPicker == "fromLensPicker")
    {
        NavigationContext.QueryString.Remove("fromLensPicker");
        //...
    }
}
于 2013-10-16T17:19:02.920 に答える
0

MainPage の OnNavigatedTo で、NavigationMode を使用して、CameraCaptureTask から戻っているかどうかを確認します。

protected override void OnNavigatedTo(NavigationEventArgs e)
{
     if(e.NavigationMode == NavigationMode.Back)
         return;

     // else continue further with CameraCaptureTask
}

また

protected override void OnNavigatedTo(NavigationEventArgs e)
{
     if(e.NavigationMode == NavigationMode.New)
         // continue further with CameraCaptureTask
}
于 2013-10-16T08:29:55.733 に答える