This question already has an answer here:
Recognize when is the app first launched WP8
(1 answer)
Closed 8 years ago.
I'm quite new on windows phone dev. I would like to detect when the user launches my app for the first time to display an explaination frame for example by calling :
if(firstLaunch)
showTheFrameToTheGuyBecauseHeLaunchedTheAppForTheFirstTime();
I would be sooooooo glad if someone could show us such a small script...
Thank you in advance guys !
I would recommend you to use the builtin applicationsettings.
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();
}
Microsoft Documentation about Settings in Windows Phone is available here.
You can simply use IsolatedStorageSettings.
if(!IsolatedStorageSettings.ApplicationSettings.Contains("first"))
{
// Do your stuff
IsolatedStorageSettings.ApplicationSettings["first"] = true;
IsolatedStorageSettings.ApplicationSettings.Save();
}
This code will do it.
Related
is there a way to check the app is installed for first time.I want this info cause i want to provide a small introduction session about the app features when user run the app for the first time.I want this to develop in windows phone 8.1 in c#
any help is welcome
Thank you
Maybe somethink like this:
On ApplicationStart:
Windows Phone 8:
if (!IsolatedStorageSettings.ApplicationSettings.Contains("FirstStart"))
{
//ShowTutorial
}else
{
IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;
if (!settings.Contains("FirstStart"))
{
settings.Add("FirstStart", "false");
}
//Start normal.
}
Here is a quickstart about Application Settings on Windows Phone: https://msdn.microsoft.com/en-us/library/windows/apps/jj714090%28v=vs.105%29.aspx
Windows Phone 8.1
On ApplicationStart:
var localSettings = Windows.Storage.ApplicationData.Current.LocalSettings;
if (localSettings.Values["FirstStart"] == null)
{
//ShowTutorial
}
else
{
localSettings.Values["FirstStart"] = "true";
}
https://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.applicationdata.localsettings.ASPx?cs-save-lang=1&cs-lang=csharp#code-snippet-2
I have a C# Windows Forms application where I eventually start another program with
Process.Start()
For all people using my software the new program now starts with English keyboard.
Is there a way to fix that issue?
FYI, the Windows Forms app is only available in English.
I have 2 ideas:
First one is to check ALL of your Project settings and look if you have somewhere set the english keyboard or just english language.
Second idea from here:
1- For better performance, get the machine installed language as
follows: C#
public static InputLanguage GetInputLanguageByName(string inputName)
{
foreach (InputLanguage lang in InputLanguage.InstalledInputLanguages)
{
if (lang.Culture.EnglishName.ToLower().StartsWith(inputName))
return lang;
}
return null;
}
2- Set your preferred language at run time: C#
public void SetKeyboardLayout(InputLanguage layout)
{
InputLanguage.CurrentInputLanguage = layout;
}
I'm trying to set up local settings so I can store data in my Windows Mobile 8 app. The first step I'm trying is:
ApplicationDataContainer localSettings = ApplicationData.Current.LocalSettings;
Just having that in my code causes the app to fail when debugging on my device.
Any ideas why?
I have "using Windows.Storage;" set. The actual code doesn't throw up any errors.
I needed to use the IsolatedStorageSettings feature, as below:
IsolatedStorageSettings settings = IsolatedStorageSettings.ApplicationSettings;
if (!settings.Contains("test"))
{
settings.Add("test", urlText.Text);
}
else
{
settings["test"] = urlText.Text;
}
settings.Save();
In visual studio 2010, working with c#;
I open a browser with:
private IE browser;
private void Set_Browser()
{
string splashUrl = "google.com";
browser= new IE(splashUrl);
}
If a user(person) closes the browser by accident, then my application will not be able to work anymore.
QUESTIONS:
So how do I check if a user closed the browser manually?
Can I unable a user from closing the browser by adding the browser to my
application GUI as a control? [using Windows Forms]
-> How do I do that?
Last question related to this post How to use watin with WebBrowser control? (2 years old, but no decent answer too)
EDIT: The solution in give URL seems to work. Problem is that if I try to send the WebBrowser.ActivateX.. as an object to other class. Then my browser = new IE(..) returns null. It does work when I instantiate it in the form class though. Any solutions?
You can search for the process of internet explorer every x seconds and see if the browser is already running using this code:
bool isRunning = false;
foreach (Process clsProcess in Process.GetProcesses()) {
if (clsProcess.ProcessName.Contains("iexplore"))
{
isRunning = true;
break;
}
}
You can use this article
Or you can add a browser control to your application using this article
One thing you can do is hide the browser to avoid users closing it .. See this SO question.
Hiding Internet Explorer when WatiN is run
I'm using IsolatedStorageSettings class in my Windows Phone 7 project as a key-value store to remember user preferences and login credentials in my app.
The problem is, when I invoke Remove(string) method with the key and then I use Save() method to persist changes. Remove() method returns true, that means value is deleted. But when I try to get the value next time, I see that it is still there and not deleted.
Here's the code I use for deletion:
if (isolatedStore.Contains(key))
{
isolatedStore[key] = null;
}
bool del = isolatedStore.Remove(key);
isolatedStore.Save();
Here's how I get isolatedStorage instance:
private IsolatedStorageSettings isolatedStore =
IsolatedStorageSettings.ApplicationSettings;
Where do you think the problem is?
I found this block in the following link. I haven't tried to remove a key the way you're doing, though. http://social.msdn.microsoft.com/Forums/en/windowsphone7series/thread/17514c94-1f59-47b4-bb78-99694bfbb6b2
public static void DeleteObject(string key)
{
IsolatedStorageSettings.ApplicationSettings.Remove(key);
}