当我再次点击我的应用程序时获得回调方法 - Windows 商店应用程序
get a callback method when I tap on my app again - Windows Store app
我做了以下事情:
1.launched 我的应用
2.launched 另一个应用
3.tap 再次在我的应用程序上(例如从应用程序列表中取出)
在第 .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 商店应用的新手
您可能是从 Visual Studio 启动应用程序并触发 suspend/resume 您只是使用应用程序中的最小化按钮。这不适用于从 VS 启动并连接了调试器的应用程序。
要模拟 supend/resume,请使用 Visual Studio 中的生命周期事件工具栏。看起来像这样:
如果您没有找到它,请不要担心,它会在您开始在 Viusal Studio 中调试您的应用程序后立即出现。
我做了以下事情: 1.launched 我的应用 2.launched 另一个应用 3.tap 再次在我的应用程序上(例如从应用程序列表中取出)
在第 .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 商店应用的新手
您可能是从 Visual Studio 启动应用程序并触发 suspend/resume 您只是使用应用程序中的最小化按钮。这不适用于从 VS 启动并连接了调试器的应用程序。
要模拟 supend/resume,请使用 Visual Studio 中的生命周期事件工具栏。看起来像这样:
如果您没有找到它,请不要担心,它会在您开始在 Viusal Studio 中调试您的应用程序后立即出现。