Bcsf13a019_mcqs_ead

34
Windows Phone App BCSF13A019 Link to Video https://youtu.be/jHxQ1D-HL_I Date: June 8 th , 2016 (Wednesday)

Transcript of Bcsf13a019_mcqs_ead

Page 1: Bcsf13a019_mcqs_ead

Windows Phone App

BCSF13A019

Link to Video

https://youtu.be/jHxQ1D-HL_I

Date: June 8th

, 2016 (Wednesday)

Page 2: Bcsf13a019_mcqs_ead

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

Page 3: Bcsf13a019_mcqs_ead

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

Page 4: Bcsf13a019_mcqs_ead

11) App Visibility is synchronized with:

App Resume

AppClose

AppSuspend

None

Page 5: Bcsf13a019_mcqs_ead

Windows Mobile App

Development

By Maryam Iqbal BCSF13A019

Date: June 8th, 2016 (Wednesday)

Page 6: Bcsf13a019_mcqs_ead

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

Page 7: Bcsf13a019_mcqs_ead

Life Cycle of Windows Mobile Application

Page 8: Bcsf13a019_mcqs_ead

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.

Page 9: Bcsf13a019_mcqs_ead

Cont.

Page 10: Bcsf13a019_mcqs_ead

Cont.

App Launch

App Activation

App Suspend

App Visibility

App Resume

App Close

App Crash

App Removal

For Details: https://channel9.msdn.com/Series/Windows-Phone-8-1-Development-for-Absolute-Beginners/Part-12-Understanding-the-App-s-Lifecycle-and-Managing-State

Page 11: Bcsf13a019_mcqs_ead

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.

Page 12: Bcsf13a019_mcqs_ead

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.

Page 13: Bcsf13a019_mcqs_ead

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.

Page 14: Bcsf13a019_mcqs_ead

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.

Page 15: Bcsf13a019_mcqs_ead

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.

Page 16: Bcsf13a019_mcqs_ead

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.

Page 17: Bcsf13a019_mcqs_ead

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

Page 18: Bcsf13a019_mcqs_ead

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.

Page 19: Bcsf13a019_mcqs_ead

5 Ways to Build Mobile Apps with Visual Studio

Page 20: Bcsf13a019_mcqs_ead

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/

Page 21: Bcsf13a019_mcqs_ead

How to create Native Mobile App in VS

Page 22: Bcsf13a019_mcqs_ead

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”

Page 23: Bcsf13a019_mcqs_ead

Cont.

Page 24: Bcsf13a019_mcqs_ead

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).

Page 25: Bcsf13a019_mcqs_ead

Cont. (MainPage.xaml)

UI Code Panel

Designer View

Page 26: Bcsf13a019_mcqs_ead

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"/>

Page 27: Bcsf13a019_mcqs_ead

Cont. (MainPage.xaml)

BUTTON

TEXTBLOCK

Page 28: Bcsf13a019_mcqs_ead

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 = ""; }

Page 29: Bcsf13a019_mcqs_ead

Code to be added

Page 30: Bcsf13a019_mcqs_ead

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.

Page 31: Bcsf13a019_mcqs_ead

Cont.

It’ll take some time. So, wait.

Click this

button to see

“Hello World”

Page 32: Bcsf13a019_mcqs_ead

Cont.

Here’s the Hello World in TextBlock..

If you’ll press button again, it’ll disappear.

Page 33: Bcsf13a019_mcqs_ead

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

Page 34: Bcsf13a019_mcqs_ead

Thank You