我在windows phone dev上很新。我想检测用户何时第一次启动我的应用程序以显示解释框架,例如通过调用:
if(firstLaunch)
showTheFrameToTheGuyBecauseHeLaunchedTheAppForTheFirstTime();
如果有人能向我们展示如此小的剧本,我会非常高兴......
先谢谢你们!
答案 0 :(得分:4)
我建议你使用内置的应用程序设置。
const string settingsAppLaunched = "appLaunched";
public static bool IsFirstLaunch(){
IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;
return !(settings.Contains(settingsAppLaunched) && settings[settingsAppLaunched]);
}
public static bool Launched(){
if(IsFirstLaunch()){
IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;
settings.Add(settingsAppLaunched, true);
settings.Save();
}
}
//usage:
if(IsFirstLaunch()){
showTheFrameToTheGuyBecauseHeLaunchedTheAppForTheFirstTime();
Launched();
}
有关Windows Phone中的设置的Microsoft文档可用here。
答案 1 :(得分:2)
您只需使用IsolatedStorageSettings。
if(!IsolatedStorageSettings.ApplicationSettings.Contains("first"))
{
// Do your stuff
IsolatedStorageSettings.ApplicationSettings["first"] = true;
IsolatedStorageSettings.ApplicationSettings.Save();
}
此代码将执行此操作。