際際滷

際際滷Share a Scribd company logo
Real World State and Notification BrokerMichele LocuratoloIn collaborazione con
AgendaWhat is the State and Notification BrokerReading a System StateReacting to changesApplication launcher
What is the State and Notification Broker:Il a set of API which allow developers to:Monitoring the System State in managed code:We have more then 100 states exposedReact on system state changesCreate custom states
Now we have:A consistent model to access and manage the system statesNo P/Invoke! 100% Managed code!A lot of states exposed (more then 100)
A BIG difference
Read the battery stateDEMO
Reacting to a changesCreate an instance of the specific stateRegister to the .Changes eventImplement your code
React to the battery state changesDEMO
How we can use it (in a real world scenario)?We can:Disable  buttons /menu when the battery strength is lowSend data before battery goes down
ActiveSyncStatusPhoneCallForwardingOnLine1CradlePresentMessagingMmsUnreadMessagingOtherEmailUnreadMessagingLastEmailAccountNameMessagingTotalEmailUnreadPhoneLastIncomingCallerNameMediaPlayerTrackGenreMediaPlayerTrackTitleHeadsetPresentPhoneIncomingCallerNumberConnectionsVpnDescriptionsMessagingSmsUnreadPhoneIncomingCallerNameKeyboardPresentPhoneSimFullWiFiStateConnectedMessagingVoiceMailTotalUnreadOwnerNameConnectionsProxyCountPhoneCallOnHoldPhoneActiveCallCountMediaPlayerTrackArtistWiFiStatePowerOnTasksActivePhoneMissedCallCalendarEventBusyStatusMessagingActiveSyncAccountNameDisplayRotationPhoneCallCallingPhoneCallBarringPhoneActiveDataCallCameraPresentPhoneBlockedSimPhoneIncomingCallerContactPhoneGprsCoverageWiFiStateNetworksAvailablePhoneMissedCallsConnectionsCountPhone1xRttCoverageTasksHighPriorityPhoneIncomingCallerContactPropertyName
Behind the scenes:The Windows Mobile Registry is the central repository:SystemState: for the predefined statesRegistryState: for the custom  state
Creating your own state:Crate an instance of the RegistryState ClassReact to the changes like the classic SystemState
Create your own stateDEMO
Application LauncherStart an application when a monitored state changesStateBase implements IApplicationLaucher interfaceThe IApplicationLaucher has the capability to start an applicationInformation about the application to start are stored in the Registry
ApplicationLauncherDEMO
RemarksYou can start directly when a state changesSystemStatemonitoredState = newSystemState(SystemProperty.PowerBatteryBackupStrength);monitoredState.EnableApplicationLauncher("MyCoolApp");or when a state arrives to a specified valueSystemStatemonitoredState = new SystemState(SystemProperty.PowerBatteryBackupStrength);monitoredState.ComparisonType = StatusComparisonType.Less;monitoredState.ComparisonValue = BatteryLevel.Low;monitoredState.EnableApplicationLauncher("MyCoolApp");The second application is not running before the state value doesnt match with the criteria
In conclusion.Windows Mobile exposes more then 100 different statesWhen you need to interact with any kind of system notifications, check the System StatesYou can create your own stateUse the S&N API to produce a better softwareCheck out this open source application which uses this APIshttp://www.codeplex.com/MobilePhoneAssistant
ActiveSyncStatusPhoneCallForwardingOnLine1CradlePresentMessagingMmsUnreadMessagingOtherEmailUnreadMessagingLastEmailAccountNameMessagingTotalEmailUnreadPhoneLastIncomingCallerNameMediaPlayerTrackGenreMediaPlayerTrackTitleHeadsetPresentPhoneIncomingCallerNumberConnectionsVpnDescriptionsMessagingSmsUnreadPhoneIncomingCallerNameKeyboardPresentPhoneSimFullWiFiStateConnectedMessagingVoiceMailTotalUnreadOwnerNameConnectionsProxyCountPhoneCallOnHoldPhoneActiveCallCountMediaPlayerTrackArtistWiFiStatePowerOnTasksActivePhoneMissedCallCalendarEventBusyStatusMessagingActiveSyncAccountNameDisplayRotationPhoneCallCallingPhoneCallBarringPhoneActiveDataCallCameraPresentPhoneBlockedSimPhoneIncomingCallerContactPhoneGprsCoverageWiFiStateNetworksAvailablePhoneMissedCallsConnectionsCountPhone1xRttCoverageTasksHighPriorityPhoneIncomingCallerContactPropertyName
Link17/01/2008www.xedotnet.org19Michele Locuratolohttp://www.michelelocuratolo.commichele@locuratolo.comhttp://www.michelelocuratolo.comTwitter.com/mighell

More Related Content

Real World State And Notification Broker

Editor's Notes

  • #3: Chiedere quanti conoscono S&N e quanti lo hanno gi usato
  • #5: In the past, system states non exposedasmanagedP/InvokesrequiredInconsistentAPIstoretrieve System States
  • #6: Marcare sulla congruenza del modello di accesso agli stati
  • #7: Battery: semplice lettura di uno stato
  • #9: Battery
  • #10: Dire alla fine:Rememberwe have more than 100 states
  • #12: HKLMSystemState: general stateHKCUSystemState: user state (likeappointments)Mostrare il registro con Remote RegistryEditor
  • #14: Battery
  • #15: PersistentNotificationThe previuos (and verysimple) demo helps me to introduce the PersistentNotification.
  • #16: Battery
  • #17: Sulpunto 1, fare lesempiodellechiamateentranti e che 竪 possibileavviareil software solo se un determinatochiamantestchiamando!