简体   繁体   English

如何从另一个页面恢复该应用程序,然后将其暂停?

[英]How to resume the app with another page then the suspended?

I need to ask for a passcode every time the app was suspended (and resumed), so I have to show a corresponding page, and after the user enters the pin proceed the app resuming to the page which was shown before suspending. 每次暂停(恢复)应用程序时,我都需要输入密码,因此我必须显示相应的页面,并且在用户输入图钉之后,继续将应用程序恢复到暂停之前显示的页面。 How can I get the page to which I have to proceed? 如何获得必须进入的页面? The App.Resume event provides 2 parameters, but both of them are objects. App.Resume事件提供2个参数,但它们都是对象。 To which type I need to cast these objects to get the proper page's type? 我需要将这些对象转换为哪种类型以获得正确的页面类型? Can I get from these parameters the proper page type at all? 我能否从这些参数中获得正确的页面类型?

I mean 我的意思是

private void OnResuming(object sender, object e)
{
    //get the suspended page's type here
}

Thanks :) 谢谢 :)

I recommend the following: In OnResuming simply Navigate to the passcode page, but remember the current page before. 我建议以下内容:在OnResuming中,只需导航至密码页面,但请记住之前的当前页面。 OnResuming should look like this: OnResuming应该看起来像这样:

    //...
    // the following line returns something like e.g. "MainPage"
    var pageTypeName = ((Frame)Window.Current.Content).SourcePageType.Name;
    // store pageTypeName in app scope
    // Navigate to passcode page ...

When passcode was entered correctly navigate to the previous page. 正确输入密码后,导航至上一页。

Second Option: You can also try to navigate to the passcode page during "OnSuspending". 第二种选择:您也可以尝试在“ OnSuspending”期间导航到密码页面。 The user will see the passcode page after a resume. 恢复后,用户将看到密码页面。 After entering the code you can redirect the user to the previous page. 输入代码后,您可以将用户重定向到上一页。 Of course you also have to store the type of the current page during OnSuspending accordingly. 当然,您还必须在OnSuspending期间存储当前页面的类型。

The code shown works fine if you have an "easy" interface without eg a SplitView. 如果您具有“简易”界面而不使用例如SplitView,则显示的代码可以正常工作。 You probably have to tweak it a little if you are working with nested Frames etc. 如果您使用嵌套框架等,则可能需要稍微调整一下。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 导航到另一个页面,然后恢复应用程序 - Navigate to another page and then resume app 每当应用暂停时,在特定页面启动应用WP 8.1 - Start app at a specific page whenever app is suspended WP 8.1 应用程序在WinRT中暂停后恢复CaptureElement - Resume CaptureElement after application was suspended in WinRT 应用程序暂停时如何保持文件转换处于活动状态 - How to keep file conversion active when app is suspended 从Windows应用商店中上次查看的页面恢复应用 - Resume an app from the page last viewed in windows store 为什么在AppFabric中恢复暂停的工作流程会产生错误? - Why do resume suspended workflow in AppFabric give errors? UWP应用暂停时调用用户控件/主页方法 - Invoke user control/main page method when UWP app gets suspended 暂停应用程序时不调用OnNavigatedFrom - OnNavigatedFrom is not called when the app is suspended 如果应用程序已暂停,如何检查 AppServiceConnection 实时状态并使应用程序处于运行状态 state - How to check AppServiceConnection live status and Bring the app in running status if app has gone in suspended state 由于锁定屏幕而挂起我的应用程序时如何仍然运行它,然后唤醒设备 - How to still have my app run when it is suspended because of lock screen and then wake the device
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM