仅在第一次启动时,或在崩溃或杀死应用程序后显示启动页面

时间:2014-03-06 09:09:06

标签: windows-phone-8

请您解释一下如何在首次启动或崩溃时显示启动页面或在Windows手机中终止应用程序。

1 个答案:

答案 0 :(得分:2)

您可以使用IsolatedStorage检查应用程序是否在之前打开

private static bool hasSeenIntro;

/// <summary>Will return false only the first time a user ever runs this.
/// Everytime thereafter, a placeholder file will have been written to disk
/// and will trigger a value of true.</summary>
public static bool HasUserSeenIntro()
{
    if (hasSeenIntro) return true;

    using (var store = IsolatedStorageFile.GetUserStoreForApplication())
    {
        if (!store.FileExists(LandingBitFileName))
        {
            // just write a placeholder file one byte long so we know they've landed before
            using (var stream = store.OpenFile(LandingBitFileName, FileMode.Create))
            {
                stream.Write(new byte[] { 1 }, 0, 1);
            }
            return false;
        }

        hasSeenIntro = true;
        return true;
    }
}

对于崩溃系统,您可以使用BugSense for Windows Phone