質問

I am making a simple password managing application, which requires the user to remember one 'Master Password' to access all his/her other passwords stored on the application.

However my problem is the back button (and multitasking). As if the user (or more importantly, other person) uses these, he/she can access the app without having to go past the initial verification page.

Is there any way to deter this problem?

Or is there a way to simply kill the application when the start button is pressed? (to achieve the same effect as when you exit an app using the back button).

役に立ちましたか?

解決 2

If your application targets Windows Phone 7 (which will run on Phone 8) you can exit an app with the following line:

new Microsoft.Xna.Framework.Game().Exit();

This is found in the Microsoft.Xna.Framework.Game assembly.

他のヒント

Use the Application_Activated event in App.xaml.cs to detect this and apply your logic accordingly e.g. ask again for authentication.
There is no API to close application for Windows Phone 7. For Windows Phone 8 you can use Application.Current.Terminate();

I think I have the best solution for you. In app.xaml.cs your going to create a global variable didResume. Inside the Appication_Activated event your going to set didResume to true. Now whenever your loading a page that would require user authentication check the variable to see if the user resumed and if they did you can handle it however you like. Here's the code for the app.xaml.cs:

  public static  bool didResume = false;
  private void Application_Activated(object sender, ActivatedEventArgs e)
    {
        didResume = true;
    }

Now you just add this method to any page you want to protect:

  protected override void OnNavigatedTo(NavigationEventArgs e)
    {
        base.OnNavigatedTo(e);
        if(App.didResume)
        {
            NavigationService.Navigate(new Uri("/MainPage.xaml", UriKind.Relative));
        }
    }

I think this should work since it really doesn't call any API that might not work on windows phone 7. Its simple and secure and will provide a solid user experience. Plus since it validates whenever the page is navigated to I think it will be harder for the user to attempt to bypass some how.

In Application_Deactivated event just throw an exception

private void Application_Deactivated(object sender, DeactivatedEventArgs e)
{
    throw new Exception("System Exit");
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top