The document discusses the lifecycle of Windows Phone apps. It explains that apps can be in running, not running, or suspended states. When a user switches to another app, the current app moves to the suspended state. An app can also be suspended when the device enters a low power state. The document then covers various lifecycle events like launch, activation, suspend, resume, visibility change, close, and crash. It also discusses how to create a basic "Hello World" app in Visual Studio to demonstrate the app lifecycle.
2. MCQs
1) How many general states are there in which your application can be
in?
3
2
1
4
2) When user switches to other application, your old app moves to which
state?
Running
Not running
Suspended
None
3) An app can be in suspended state if,
User switches to some other app.
Device enters a low power state.
Both
None
4) After suspended state, app goes to which state:
Running
Not Running
Both Possible
None
5) Which event is used to show that user has closed the app?
OnClose
OnExit
None
Both
3. 6) On app crash, when the user activates an app, its activation event
handler receives a value:
ApplicationExecutionState
ApplicationRunningState
None
Both
7) In how many ways a windows mobile app can be created in Visual
Studio?
3
4
5
6
8) App is a sealed class which is i herited fro App class.
True
False
Unknown
None
9) Default methods available in App.xaml.cs file are:
OnLaunched & OnSuspended
OnLaunched & OnSuspending
OnLaunching & OnSuspending
None
10) To participate in activation, your app must register to receive the
WinJS activated event for XAML
Override OnActivated for HTML
WinJS activated event for HTML
None
6. Prerequisite
VS Studio
Download the Windows Phone SDK 8.0
Already know C#, XAML
Register your phone for development (Optional)
https://msdn.microsoft.com/en-
us/library/windows/apps/ff769508%28v=vs.105%29.aspx
8. Life Cycle of Windows Mobile App
Mainly an application can be in any of the following 3 states:
Running
Not running
Suspended
But other than these states, your app can be in some other states
as well which are discussed on upcoming slides.
11. App Launch
An app is launched whenever it is activated by the user
and the app process was previously in the NotRunning
state.
An app could be in the NotRunning state because it has
never been launched, because it was running but then
crashed, or because it was suspended but then couldn't
be kept in memory and was terminated by the system.
12. App Activation
An app can be activated by the user through a
variety of contracts and extensions.
To participate in activation, your app must register to
receive the WinJS activated event (HTML) or override
the OnActivated method (XAML).
For HTML, WebUIApplication.activated is another
event you can handle for activation.
13. App Suspend
An app can be suspended when the user switches
away from it or when the device enters a low
power state.
When the user moves an app to the background,
Windows waits a few seconds to see whether the
user immediately switches back to the app. If the
user does not switch back within this time window,
Windows suspends the app.
14. App Visibility
When the user switches from your app to another app, your app is
no longer visible but remains in the Running state until Windows can
suspend it. If the user switches away from your app but activates or
switches back to it before it can suspended, the app remains in the
Running state.
Your app doesn't receive an activation event when app visibility
changes, because the app is still running. Windows simply switches
to and from the app as necessary. If your app needs to do
something when the user switches away and back, it can handle
the visibilitychange event (for HTML) or Window.VisibilityChanged
event (for XAML).
The visibility event is not serialized with the suspend/resume or
activation events. Don't assume that these events come in a
particular order.
15. App Resume
A suspended app is resumed when the user switches to it
or when the device comes out of a low power state.
When an app is resumed from the Suspended state, it
enters the Running state and continues from where it was
when it was suspended. No app data is lost, so long as it
was stored in memory. Therefore, most apps don't need
to do anything when they are resumed.
16. App Close
Generally, users don't need to close apps, they can let Windows
manage them. However, users can choose to close an app using
the close gesture or by pressing Alt+F4 on Windows or by using the
task switcher on Windows Phone.
There's no special event to indicate that the user has closed an
app.
After an app has been closed by the user, it's suspended and
terminated, and then enters the NotRunning state.
In Windows 8.1 and later, after an app has been closed by the
user, the app is removed from the screen and switch list but not
explicitly terminated.
17. App Crash
Apps are required to follow the system crash experience, which is
to simply return to the Start screen.
The system crash experience is designed to get users back to what
they were doing as quickly as possible, so you shouldn't provide a
warning dialog or other notification because that'll cause a delay
for the user.
When the user activates an app after it crashes, its activation
event handler receives an ApplicationExecutionState value of
NotRunning, and should display its initial UI and data.
After a crash, don't routinely use the app data you would have
used for Resuming with Suspended because that data could be
corrupt
18. App Removal
When a user deletes your app, the app is removed,
along with all its local data.
Removing an app doesn't affect the user's data that
was stored in common locations, such as files in the
Documents or Pictures libraries.
19. 5 Ways to Build
Mobile Apps with
Visual Studio
20. 5 Ways to Build Mobile Apps with Visual
Studio
There are 5 different ways of creating a mobile app in Visual Studio, which
are:
Web (Part 1) – Responsive Design
Web (Part 2) – Mobile Optimized Web Pages
Hybrid App
Native App
Xamarin
We’ll use “Native App Way” You can read about all of them from :
http://developer.telerik.com/featured/5-ways-to-build-mobile-apps-with-
visual-studio/
22. Creation
Let’s create a simple “Hello World App”
Open VS 2013 or whatever version you have (2010, 2012 etc.)
From top Menu Bar:
File → New Project or CTRL+SHIFT+N.
From new Dialogue Box:
Visual C# → Store Apps → Windows Phone Apps → Blank App
→ Give Name “HelloWolrd”
24. Cont.
Once you’ve created a project you’ll see App.xmal.cs file.
This file represents a class names as “App” which is a sealed
class and inherited from “Application”.
Moreover it contains some methods:
OnLaunched
RootFrame_FirstNavigated
OnSuspending
Open MainPage.xaml. You’ll see a designer view and a code
panel to design User Interface(UI).
26. Cont. (MainPage.xaml)
Now, first we’ll make a button. If you know WPF then it would
be very easy.
To make a button write these lines inside <grid></grid>
<Button Content="Click ME" Click="btnClick"
HorizontalAlignment="Left" Margin="140,94,0,0"
VerticalAlignment="Top"/>
As, we need something where text “Hello World” can be
displayed so, we’ll use textblock not textbox because that is
for taking input. So, we’ll use textblock.
<TextBlock x:Name="myBlock" FontSize="25"
TextAlignment="Center" HorizontalAlignment="Left"
Margin="43,200,0,0" TextWrapping="Wrap"
VerticalAlignment="Top" Height="175" Width="305"/>
28. Cont. (MainPage.xaml.cs)
Now write click event against the button we’ve just created.
Open MainPage.xaml.cs file or double click on button created in
design.
Write following code in click event:
private void btnClick(object sender, RoutedEventArgs e)
{
if (myBlock.Text == "")
{
myBlock.Text = "Hello World!";
}
else
myBlock.Text = "";
}
30. Cont.
Now run you application.
Make sure HYPER-V option is enabled in your
computer. If not then you can enable it from “turn
windows feature on or off menu” (available in
control panel).
Select “Emulator 8.1 WVGA 4 inch 512 MB”
Press CTRL+F5 or simply click the “Emulator 8.1
WVGA 4 inch 512 MB” button.
33. For further learning, you may visit:
https://channel9.msdn.com/Series/Windows-Phone-8-1-
Development-for-Absolute-Beginners
https://msdn.microsoft.com/en-
us/library/windows/apps/ff402529%28v=vs.105%29.aspx
https://channel9.msdn.com/Series/Building-Apps-for-
Windows-Phone-8-Jump-Start