【问题标题】:get a callback method when I tap on my app again - Windows Store app当我再次点击我的应用程序时获取回调方法 - Windows Store 应用程序
【发布时间】:2015-09-02 10:10:22
【问题描述】:

我做了以下事情: 1.启动我的应用程序 2.启动另一个应用程序 3.再次点击我的应用(例如从应用列表中取出)

在第 .3 步,我希望收到消息回调,但我没有。

在文件 App.xaml.cs 中,我添加了 onResuming this 方法

方式:

public App()
{
        //this.askToBeOnLockScreen();
        this.createRegisterBgTask();

        this.InitializeComponent();

        this.Suspending += OnSuspending;
        this.Resuming += OnResuming;
    }

这里我重写了 2 个方法:

    private void OnResuming(object sender, object e)
    {
        Debug.WriteLine("OnResuming ...................");
    }





    private void OnSuspending(object sender, SuspendingEventArgs e)
    {
        Debug.WriteLine("onsuspending ......................................................");
        var deferral = e.SuspendingOperation.GetDeferral();

        deferral.Complete();
    }

甚至没有调用 onsuspending。

我做错了什么?

我是 Windows 商店应用的新手

【问题讨论】:

    标签: c# windows-store-apps


    【解决方案1】:

    您可能正在从 Visual Studio 启动应用程序并触发暂停/恢复,您只需使用应用程序中的最小化按钮。这不适用于从 VS 启动并连接了调试器的应用程序。

    要模拟挂起/恢复,请使用 Visual Studio 中的生命周期事件工具栏。看起来像这样:

    如果您没有找到它,请不要担心,它会在您开始在 Viusal Studio 中调试您的应用后立即出现。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-09-21
    • 2020-12-20
    • 2014-06-28
    • 2013-12-04
    • 2016-04-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多