SlideShare ist ein Scribd-Unternehmen logo
1 von 24
NOKIA WEBINAR

IL CICLO DI VITA:
FAST APPLICATION
SWITCHING E FAST RESUME
Dan Ardelean
Nokia Developer Champion
dan@xpresscode.eu Twitter: @danardelean
AGENDA
Stack di navigazione
Launching & Closing
Dormant & Tombstoned
Dizionari di stato
Fast Application Resume
Obscured & Unobscured
Async & await
LE BASI
•

Modello di navigazione Page-Based

•

Per implementare questo modello di navigazione ogni applicazione ha uno
«Back Stack»
•
•
•

Navigazione verso una nuova pagina la vecchia viene inserita in Back Stack
Quando viene premuto il tasto Back o chiamato il metodo GoBack l’applicazione ritorna
alla prima pagina dentro Back Stack
Se Back Stack è vuoto quando si naviga indietro l’applicazione viene chiusa
STACK DI NAVIGAZIONE
•

Possiamo manualmente rimuovere elementi dallo stack
private void PurgeBackStackButton_Click(object sender, RoutedEventArgs
e)
{
while (NavigationService.CanGoBack)
NavigationService.RemoveBackEntry();
}

•
•

Non possiamo manualmente aggiungere elementi
Le pagine possono essere notificate se vengono rimosse dallo stack
protected override void OnRemovedFromJournal(JournalEntryRemovedEventArgs
e)
{
base.OnRemovedFromJournal(e);
}
LANCIO APPLICAZIONE
Not running

Launching

Running
CHIUSURA & DISATTIVAZIONE
Not running

Closing

Exit
Application_Closing

Launching

Running

Deactivate
Application_Deactivated

Dormant

Deactivating

Dormant
DORMANT
Not running

Istanza in memoria
Closing

Stato applicazione, data e oggetti non vengono
modificati
Deve essere pronta per essere chiusa

Launching

Running

Activating

Deactivating

Dormant
Tombstoned

Dormant

Attiva
TOMBSTONED
Da Dormant a Tombstone «memory based»

Not running

Salva i dizionari di stato e lo stack di navigazione
Bisogna ricaricare i dati

Launching

Closing

Running

Activating

Deactivating

Dormant
Tombstoned
TOMBSTONED O
DORMANT?

Not running

Launching

Closing

private void Application_Activated(object sender, ActivatedEventArgs e)
{
if (e.IsApplicationInstancePreserved)
{
// Dormant
}
else
{
// Tombstoned
}
}

Running

Activating

Deactivating

Dormant
Tombstoned
FAST APPLICATION RESUME
Not running

Riattiva l’istanza dormant se l’utente lancia una
nuova istanza

Closing

Necessario per le applicazioni che fanno
tracking della posizione e non solo

Launching

Running

Activating

Deactivating

Dormant

Tombstoned
TERMINAZIONE NORMALE

M
O

O
O
DORMANT
O
O

O

IsApplicationInstancePreserved
==true
TOMBSTONED
O
O

M
IsApplicationInstancePreserved
==false

O
TOMBSTONED
O

O

o

O
O
STATO APPLICAZIONE
•

3 Dizionari
•

Pagina:
PhoneApplicationPage.State

•

Istanza app
PhoneApplicationService.Current.State

•

Applicazione
System.IO.IsolatedStorage.IsolatedStorageSettings.ApplicationSettings
MANAGEMENT DELLE RISORSE
O
O

MediaPlayer.Pause
MediaElement.Pause
VibrateController.Stop
Photocamera.Dispose
MANAGEMENT DELLE RISORSE

Socket rimangano scollegati
MediaElement non connesso
Photocamera disposed

O
FAST APPLICATION RESUME
•

Riattiva l’istanza Dormant, se esiste, quando l’utente lancia nuovamente
l’applicazione

•

Per abilitare la funzionalità bisogna modificare
PropertiesWMAppManifest.xml
<Tasks>
<DefaultTask
</Tasks>

Name ="_default" NavigationPage="MainPage.xaml"
ActivationPolicy="Resume">
OBSCURED & UNOBSCURED

•

Quando l’interfaccia utente viene oscurata: notifiche
toast, lockscreen, chiamata in arrivo
L’applicazione continua girare in background

•

Per far girare l’applicazione dietro Lockscreen

•

PhoneApplicationService.Current.ApplicationIdleDetectionMode = IdleDetectionMode.Disabled;

•

Per disabilitare il Lockscreen
PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled;
ASYNC E AWAIT
•

Cosa succede quando usiamo async e await per Application_Closing e
Application_Deactivate?

•

Meccanismo per applicazioni Windows Store
var deferral = e.SuspendingOperation.GetDeferral();
//TODO: Save application state and stop any background activity.
await ExecuteAsync();
deferral.Complete();
Grazie!
Blog: sviluppomobile.blogspot.com
Email: dan@xpresscode.eu
Twitter: @danardelean

© 2013 Nokia. All rights reserved.
© 2013 Microsoft. All rights reserved.

10/13/2013

Weitere ähnliche Inhalte

Andere mochten auch

Resume of Kaptan Singh new
Resume of Kaptan Singh newResume of Kaptan Singh new
Resume of Kaptan Singh newkaptan singh
 
Bomba Blast Resume and Interview Tips
Bomba Blast Resume and Interview TipsBomba Blast Resume and Interview Tips
Bomba Blast Resume and Interview TipsJennifer Arguello
 
Resume Alejandro Garcia De Frenza
Resume Alejandro Garcia De FrenzaResume Alejandro Garcia De Frenza
Resume Alejandro Garcia De Frenzagarciadefrenza
 
Visual resume - Atul Tanawade
Visual resume - Atul TanawadeVisual resume - Atul Tanawade
Visual resume - Atul TanawadeAtul Tanawade
 
Resume_Jerry Misere_gm2
Resume_Jerry Misere_gm2Resume_Jerry Misere_gm2
Resume_Jerry Misere_gm2Jerry Misere
 

Andere mochten auch (8)

Resume of Kaptan Singh new
Resume of Kaptan Singh newResume of Kaptan Singh new
Resume of Kaptan Singh new
 
Bomba Blast Resume and Interview Tips
Bomba Blast Resume and Interview TipsBomba Blast Resume and Interview Tips
Bomba Blast Resume and Interview Tips
 
Resume Alejandro Garcia De Frenza
Resume Alejandro Garcia De FrenzaResume Alejandro Garcia De Frenza
Resume Alejandro Garcia De Frenza
 
Visual resume - Atul Tanawade
Visual resume - Atul TanawadeVisual resume - Atul Tanawade
Visual resume - Atul Tanawade
 
2012 Resume
2012 Resume2012 Resume
2012 Resume
 
Resume_Jerry Misere_gm2
Resume_Jerry Misere_gm2Resume_Jerry Misere_gm2
Resume_Jerry Misere_gm2
 
Resume
ResumeResume
Resume
 
Michael Olinski Resume
Michael Olinski ResumeMichael Olinski Resume
Michael Olinski Resume
 

Mehr von Dan Ardelean

CI/CD for mobile development using AppCenter
CI/CD for mobile development using AppCenterCI/CD for mobile development using AppCenter
CI/CD for mobile development using AppCenterDan Ardelean
 
CI/CD for mobile development using Visual Studio App Center
CI/CD for mobile development using Visual Studio App CenterCI/CD for mobile development using Visual Studio App Center
CI/CD for mobile development using Visual Studio App CenterDan Ardelean
 
Visual Studio App Center: CI/CD para mobile devs
Visual Studio App Center: CI/CD para mobile devsVisual Studio App Center: CI/CD para mobile devs
Visual Studio App Center: CI/CD para mobile devsDan Ardelean
 
Desarrollo multiplataforma con el framework .net
Desarrollo multiplataforma con el framework .netDesarrollo multiplataforma con el framework .net
Desarrollo multiplataforma con el framework .netDan Ardelean
 
Xamarin.forms a different approach to native cross platform mobile development
Xamarin.forms a different approach to native cross platform mobile developmentXamarin.forms a different approach to native cross platform mobile development
Xamarin.forms a different approach to native cross platform mobile developmentDan Ardelean
 
Xamarin.Forms a different approach to cross platform natove mobile development
Xamarin.Forms a different approach to cross platform natove mobile developmentXamarin.Forms a different approach to cross platform natove mobile development
Xamarin.Forms a different approach to cross platform natove mobile developmentDan Ardelean
 
Xamarin - Under the bridge
Xamarin - Under the bridgeXamarin - Under the bridge
Xamarin - Under the bridgeDan Ardelean
 
Sviluppo x platform con xamarin
Sviluppo x platform con xamarin Sviluppo x platform con xamarin
Sviluppo x platform con xamarin Dan Ardelean
 
Xamarin - why not ?
Xamarin -  why not ?Xamarin -  why not ?
Xamarin - why not ?Dan Ardelean
 
Share more code on iOS, Android and Windows with Portable Class Libraries
Share more code on iOS, Android and Windows with Portable Class LibrariesShare more code on iOS, Android and Windows with Portable Class Libraries
Share more code on iOS, Android and Windows with Portable Class LibrariesDan Ardelean
 
iBeacons for everyone
iBeacons for everyoneiBeacons for everyone
iBeacons for everyoneDan Ardelean
 
Xamarin Dev Days 2016 introduction to xamarin
Xamarin Dev Days 2016   introduction to xamarinXamarin Dev Days 2016   introduction to xamarin
Xamarin Dev Days 2016 introduction to xamarinDan Ardelean
 
A new world of possibilities for contextual awareness with beacons
A new world of possibilities for contextual awareness with beaconsA new world of possibilities for contextual awareness with beacons
A new world of possibilities for contextual awareness with beaconsDan Ardelean
 
C sharp day 2015 c# patterns- cross-platform
C sharp day 2015   c# patterns- cross-platform  C sharp day 2015   c# patterns- cross-platform
C sharp day 2015 c# patterns- cross-platform Dan Ardelean
 
Utilizzo dei beacon con windows 10
Utilizzo dei beacon con windows 10Utilizzo dei beacon con windows 10
Utilizzo dei beacon con windows 10Dan Ardelean
 
Develop for Windows 10 (Preview)
Develop for Windows 10 (Preview)Develop for Windows 10 (Preview)
Develop for Windows 10 (Preview)Dan Ardelean
 
Community Days 2015 Introduzione a Xamarin
Community Days 2015  Introduzione a XamarinCommunity Days 2015  Introduzione a Xamarin
Community Days 2015 Introduzione a XamarinDan Ardelean
 
Sviluppo di app cross platform con xamarin e C#
Sviluppo di app cross platform con xamarin e C#Sviluppo di app cross platform con xamarin e C#
Sviluppo di app cross platform con xamarin e C#Dan Ardelean
 
WP04 -Sensori e hardware con Windows Phone 8.1
WP04 -Sensori e hardware con Windows Phone 8.1WP04 -Sensori e hardware con Windows Phone 8.1
WP04 -Sensori e hardware con Windows Phone 8.1Dan Ardelean
 
Bluetooth LE & Lumia Sensor Core
Bluetooth LE & Lumia Sensor CoreBluetooth LE & Lumia Sensor Core
Bluetooth LE & Lumia Sensor CoreDan Ardelean
 

Mehr von Dan Ardelean (20)

CI/CD for mobile development using AppCenter
CI/CD for mobile development using AppCenterCI/CD for mobile development using AppCenter
CI/CD for mobile development using AppCenter
 
CI/CD for mobile development using Visual Studio App Center
CI/CD for mobile development using Visual Studio App CenterCI/CD for mobile development using Visual Studio App Center
CI/CD for mobile development using Visual Studio App Center
 
Visual Studio App Center: CI/CD para mobile devs
Visual Studio App Center: CI/CD para mobile devsVisual Studio App Center: CI/CD para mobile devs
Visual Studio App Center: CI/CD para mobile devs
 
Desarrollo multiplataforma con el framework .net
Desarrollo multiplataforma con el framework .netDesarrollo multiplataforma con el framework .net
Desarrollo multiplataforma con el framework .net
 
Xamarin.forms a different approach to native cross platform mobile development
Xamarin.forms a different approach to native cross platform mobile developmentXamarin.forms a different approach to native cross platform mobile development
Xamarin.forms a different approach to native cross platform mobile development
 
Xamarin.Forms a different approach to cross platform natove mobile development
Xamarin.Forms a different approach to cross platform natove mobile developmentXamarin.Forms a different approach to cross platform natove mobile development
Xamarin.Forms a different approach to cross platform natove mobile development
 
Xamarin - Under the bridge
Xamarin - Under the bridgeXamarin - Under the bridge
Xamarin - Under the bridge
 
Sviluppo x platform con xamarin
Sviluppo x platform con xamarin Sviluppo x platform con xamarin
Sviluppo x platform con xamarin
 
Xamarin - why not ?
Xamarin -  why not ?Xamarin -  why not ?
Xamarin - why not ?
 
Share more code on iOS, Android and Windows with Portable Class Libraries
Share more code on iOS, Android and Windows with Portable Class LibrariesShare more code on iOS, Android and Windows with Portable Class Libraries
Share more code on iOS, Android and Windows with Portable Class Libraries
 
iBeacons for everyone
iBeacons for everyoneiBeacons for everyone
iBeacons for everyone
 
Xamarin Dev Days 2016 introduction to xamarin
Xamarin Dev Days 2016   introduction to xamarinXamarin Dev Days 2016   introduction to xamarin
Xamarin Dev Days 2016 introduction to xamarin
 
A new world of possibilities for contextual awareness with beacons
A new world of possibilities for contextual awareness with beaconsA new world of possibilities for contextual awareness with beacons
A new world of possibilities for contextual awareness with beacons
 
C sharp day 2015 c# patterns- cross-platform
C sharp day 2015   c# patterns- cross-platform  C sharp day 2015   c# patterns- cross-platform
C sharp day 2015 c# patterns- cross-platform
 
Utilizzo dei beacon con windows 10
Utilizzo dei beacon con windows 10Utilizzo dei beacon con windows 10
Utilizzo dei beacon con windows 10
 
Develop for Windows 10 (Preview)
Develop for Windows 10 (Preview)Develop for Windows 10 (Preview)
Develop for Windows 10 (Preview)
 
Community Days 2015 Introduzione a Xamarin
Community Days 2015  Introduzione a XamarinCommunity Days 2015  Introduzione a Xamarin
Community Days 2015 Introduzione a Xamarin
 
Sviluppo di app cross platform con xamarin e C#
Sviluppo di app cross platform con xamarin e C#Sviluppo di app cross platform con xamarin e C#
Sviluppo di app cross platform con xamarin e C#
 
WP04 -Sensori e hardware con Windows Phone 8.1
WP04 -Sensori e hardware con Windows Phone 8.1WP04 -Sensori e hardware con Windows Phone 8.1
WP04 -Sensori e hardware con Windows Phone 8.1
 
Bluetooth LE & Lumia Sensor Core
Bluetooth LE & Lumia Sensor CoreBluetooth LE & Lumia Sensor Core
Bluetooth LE & Lumia Sensor Core
 

Il ciclo di vita fast application switching e fast resume

Hinweis der Redaktion

  1. ComeSilverlight per comodità dei navigazione
  2. Attenzione per la userexperienceVengono aggiunte quando navighiamo
  3. Solo una sola applicazione in Foreground
  4. Back nellapaginainizialedella app chiudel’applicazioneL’applicazione viene sospesa quando non ha più focusSe l’istanza dormant non viene più riattivata Application_Closing = Application_DeactivatedDormant eventi utenti o esterni – chiamata, lockscreen
  5. Dormant siriattivano molto veloceSe la cache si riempia l’applicazione dormant viene tombstonedUna volta dormant non esiste la garanzia che l’istanza verrà riattivataFino 8 applicazioni nello stack
  6. Processo viene terminato l’istanza viene mantenutaIl sistema operativo ha bisogno di più risorse
  7. Il programmatoredevegestire le due situazioni in mododiversoQuando un utentelanciaunanuovaistanza: start screen, listaapplicazioni o deep link: secondary tile, reminder speech input, file o protocol association se esisteunaistanzasospesavienecancellata/scartata
  8. Da usare con prudenza ma vedremmo più avanti perché – User Experience «strana»Ci sono solo 2 casi quando non abbiamo eventi quando l’applicazione va in eccezione ho viene chiamata Application.Terminate
  9. Tombstone sempre prima dello stack8 applicazione dentro backstack
  10. Lancio costruttore second pageAttenzione Non siamo passati per MainPage
  11. Singola pagina 2MBTutta l’istanza 4MBTroppi dati: consuma batteria, incrementa il tempo di pause/ripristino
  12. Tombstone sempre prima dello stack8 applicazione dentro backstack
  13. L’utente ripristina le risorse OnNavigatedTo
  14. Start screen, app menu, tilesHo solo l’evento di Application_Activated – no Application_Launching no costruttoreBisogna fare edit a mano del file
  15. RootFrame_Navigating per la demo non dimenticare
  16. Incoming SMS non alza l’evento ObscuredNon sempre esiste un matchingObscured &amp; UnobscuredEsempio motion in un gioco meglio disabilitare lockscreen