首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >提示用户进行应用反馈

提示用户进行应用反馈
EN

Stack Overflow用户
提问于 2015-04-08 16:41:44
回答 1查看 103关注 0票数 0

当他们第五次打开我的应用程序时,我试图让应用程序审查提示出现,但我似乎没有任何运气。我试过在这个网站上使用代码,但它对我不起作用。还有其他人知道的吗?

connection/archive/2013/07/25/prompting-for-feedback-within-your-windows-phone-or-windows-8-app-game.aspx

代码语言:javascript
复制
    async protected override void OnLaunched(LaunchActivatedEventArgs e)
    {
        #if DEBUG
        if (System.Diagnostics.Debugger.IsAttached)
        {
            this.DebugSettings.EnableFrameRateCounter = true;
        }
        #endif

        Frame rootFrame = Window.Current.Content as Frame;

        // Do not repeat app initialization when the Window already has content,
        // just ensure that the window is active
        if (rootFrame == null)
        {
            // Create a Frame to act as the navigation context and navigate to the first page
            rootFrame = new Frame();
            // Set the default language
            rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0];

            rootFrame.NavigationFailed += OnNavigationFailed;

            if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
            {
                //TODO: Load state from previously suspended application
            }

            // Place the frame in the current Window
            Window.Current.Content = rootFrame;
        }

        if (rootFrame.Content == null)
        {
            // When the navigation stack isn't restored navigate to the first page,
            // configuring the new page by passing required information as a navigation
            // parameter
            rootFrame.Navigate(typeof(MainPage), e.Arguments);
        }
        // Ensure the current window is active
        Window.Current.Activate();

        int started = 0;
        if (Windows.Storage.ApplicationData.Current.RoamingSettings.Values.ContainsKey("started"))
        {
            started = (int)Windows.Storage.ApplicationData.Current.RoamingSettings.Values["started"];
        }

        started++;
        Windows.Storage.ApplicationData.Current.RoamingSettings.Values["started"] = started;

        if (started == 3)
        {
            var md = new Windows.UI.Popups.MessageDialog("Thank you for using this app?", "Please review my app");
            bool? reviewresult = null;
            md.Commands.Add(new Windows.UI.Popups.UICommand("OK", new Windows.UI.Popups.UICommandInvokedHandler((cmd) => reviewresult = true)));
            md.Commands.Add(new Windows.UI.Popups.UICommand("Cancel", new Windows.UI.Popups.UICommandInvokedHandler((cmd) => reviewresult = false)));
            await md.ShowAsync();
            if (reviewresult == true)
            {
                string familyName = Package.Current.Id.FamilyName;
                await Windows.System.Launcher.LaunchUriAsync(new Uri(string.Format("ms-windows-store:REVIEW?PFN={0}", familyName)));
            }
        }
    }
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-04-09 01:17:38

在应用程序初始化到可以启动MessageDialog之前,您将调用它。

如果您查看正在复制的这篇文章,您将看到它将在调用OnLaunched ()之后将新代码放在Window.Current.Activate()方法的底部,而不是在OnLaunched方法的开头。

如果您这样做,那么对话框将按需要工作。

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29520539

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档