Eduardo Ortega MVP Device Application Development Multitasking Eduardo Ortega MVP Device Application Development
Windows Phone 7.5 Modelo de ejecución
Modelo de ejecución Mango introduce un nuevo estado: Dormant Reanudación de aplicaciones rápida (sin Resuming…) Se busca experiencia de usuario rápida y receptiva Una sola aplicación en primer plano Experiencia de navegación entre aplicaciones consistente Novedad en Mango: Mantener pulsado back button para cambiar a la aplicación anterior
Ciclo de vida de una aplicación
Ciclo de vida de una aplicación Rápida reanudación de App running deactivated dormant activated Estado conservado! IsAppInstancePreserved == true Guardar Estado! Tombstoned Tombstone App más antigua Desasociar recursos del teléfono Threads & timers suspendidos
Modelo de aplicación OnNavigatedFrom/Deactivated MIX 11 4/1/2017 Modelo de aplicación OnNavigatedFrom/Deactivated Salvar estado de página/ aplicación OnNavigatedTo/Activated Resaturar estado de página/aplicación si tombstoning WP7: la mayoría de las veces Apps Tombstoned Mango: Apps Tombstoned a veces © 2011 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Resumiendo la aplicación… private void Application_Activated(object sender, ActivatedEventArgs e) { if (e.IsApplicationInstancePreserved) // Dormant – objetos intactos en memoria } else // Tombstoned – necesita recargar los datos 7
Fast Application Switching 4/1/2017 6:51 PM Fast Application Switching © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Windows Phone 7.5 Background Tasks
Capacidades de multitasking Background Agents Periodic Resource Intensive Background Transfer Service Alarms and Reminders Background Audio
Windows Phone 7.5 Background Agents
Background Agents Agentes Una aplicación solo puede tener uno de cada Periodicos Recursos Intensivos Una aplicación solo puede tener uno de cada Inicializado en primer plano, se ejecuta en segundo plano Persiste entre reinicios Control de usuario de la configuración Maximo del sistema 18 agentes periódicos Los agentes se ejecutan hasta 14 días (pueden ser renovados)
Tipos de agentes Agentes de Recursos Intensivos Agentes Periodicos Ocurrencia Fuente externa Red no celular Duración 10 minutos Restricciones <= 6 MB Memoria Agentes Periodicos Ocurrencia Cada 30 min Duración ~15 seconds Restricciones <= 6 MB Memoria <=10% CPU 1313 Windows Phone
Funcionalidades de los agentes Permitidas Restringidas Tiles Toast Location Network R/W ISO store Sockets Most framework APIs Display UI XNA libraries Microphone and Camera Sensors Play audio (may only use background audio APIs) 1414
Depurando un Background Task #if DEBUG_AGENT ScheduledActionService.LaunchForTest(taskName, TimeSpan.FromSeconds(60)); #endif 1515
Background Agents 4/1/2017 6:51 PM © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Windows Phone 7.5 Background Notification Services
Alarmas vs Recordatorios Rich information Integrates with other reminders Snooze and Dismiss Launch app Follows the phones global settings Modal Snooze and Dismiss Sound customization No app invocation No stacking
Recordatorios
Alarmas
Background Notification Services 4/1/2017 6:51 PM Background Notification Services © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Windows Phone 7.5 Background Audio
Background Audio Mango proporciona 2 agentes para reproducción de audio en segundo plano AudioPlayerAgent reproducción de audio basada en URIs locales o remotas Rutas locales a archivos del almacenamiento aislado URL a un archivo remoto Restricción: archivos con formato compatible (.mp3 o .wav) AudioStreamingAgent audio stream de la web
Espacio de nombres: Microsoft.Phone.BackgroundAudio Clase Descripción AudioPlayerAgent Implementación de BackgroundAgent específica para reproducir audio en background AudioStreamer Stream de audio que puede reproducirse mediante el reproductor del sistema AudioStreamingAgent Agente en segundo plano que reproduce streaming por pista AudioTrack Pista de audio BackgroundAudioPlayer Proporciona acceso en background a funcionalidades de reproducción como reproducir, pausar, adelantar o rebobinar Enumeración Descripción Valores EnabledPalyerControls Especifica los controles del reproductor habilitados en el interfaz de usuario None, SkipNext, SkipPrevious, FastForward,Rewind, Pause, All PlayState Posibles estados en los que se encuentra el reproductor con respecto a la aplicación actual con audio en background Unknown, Stopped, Paused, Playing, BufferingStarted, BufferingStopped, TrackReady, TrackEnded, Rewind, FasForwarding, Shutdown, Error UserAction Posibles acciones del usuario Stop, Pause, Play, SkipNext, SkipPrevious, FastForward, Rewind, Seek
Background Audio Demo: How To: Play BackgroundAudio http://msdn.microsoft.com/en-us/library/hh202978(v=VS.92).aspx http://dotnettrain.blogspot.com/2011/06/windows-phone-mango-background-audio.html http://www.c-sharpcorner.com/UploadFile/dhananjaycoder/7687/
Background Audio 4/1/2017 6:51 PM © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Windows Phone 7.5 Background File Transfer
Transferencia de archivos en Background Descargas archivos ejecutándose segundo plano Continúan aunque aplicación no esté ejecutándose primer plano Posibilidad de encolar transferencias (subidas o descargas) APIs consulta estado transferencias e indicadores de progreso Espacio de nombres: Microsoft.Phone.BackgroundTransferService BackgroundTransferService gestión transferencias existentes BackgroundTransferRequest una única petición GET HTTP descarga y POST HTTP subida
Requisitos de la aplicación Transferencias iniciadas por el usuario o consciente de que se están ejecutando Posibilidad de mostrar transferencias en proceso Posibilidad de cancelar transferencias activas o pendientes Posibilidad forzar transferencias sólo cuando haya WiFi Obligatorio Recomendado
Restricciones del sistema de archivos Transferencias requieren ruta archivo local Descargas ruta específica de almacenamiento Subidas ruta en la que se encuentra el archivo a enviar Todas las rutas locales en almacenamiento aislado en directorio Transfers Creado por el SO durante instalación Puede albergar estructura de directorio adicional Iniciar transferencia fuera directorio Transfers Exception!!
Políticas de transferencia de archivos Transferencias iniciadas cuando se cumplan requisitos BackgroundTransferRequest.TransferPreferences SO obliga a cumplir restricciones Tamaños Máximo archivo subida 5MB Máximo tamaño de descarga en conexión de datos 20 MB (Si se sobrepasa TransferPreferences cambia a AllowBattery se precisa WiFi para la transferencia) Máximo tamaño de descarga sobre WiFi sin alimentación externa 100MB Máximo tamaño de descarga sobre WiFi con alimentación externa y TransferPreferences = None o AllowCellular Sin límite Máximo número de peticiones en cola (activas y pendientes) / aplicación 5 ( transferencias no eliminadas de la cola automáticamente aplicaciones deben llamar al método Remove(backgroundTransferRequest)
Políticas de transferencia de archivos SO obliga a cumplir restricciones Servicio de transferencia segundo plano No se ejecuta en redes 2G EDGE GPRS Estándar Requiere redes 3G o superiores Límites Máximo número total de transferencias concurrentes (de todas las aplicaciones del dispositivo) 2 Máximo número total de transferencias encoladas 500 Máximo número de cabeceras HTTP por petición 10 Máximo tamaño de cabeceras HTTP 16K cada una
Background File Transfer 4/1/2017 6:51 PM Background File Transfer © 2010 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Q&A
GRACIAS www.micmovilidad.es Eduardo Ortega http://geeks.ms/blogs/eduardoortega www.micmovilidad.es Jose Antonio Gallego http://geeks.ms/blogs/jagallego @lmovilero