real world state and notification broker
TRANSCRIPT
Real World State and Notification Broker
» Michele Locuratolo
In collaborazione con
Agenda
» What is the State and Notification Broker» Reading a System State» Reacting to changes» Application 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 exposed
» React on system state changes» Create custom states
Now we have:
» A consistent model to access and manage the system states
» No P/Invoke! 100% Managed code!» A lot of states exposed (more then 100)
A BIG difference
todayScreen• SystemProperty.DisplayRotation
Battery• SystemProperty.PowerBatteryStrength
yesterday
Screen:• GetSystemMetrics • Screen.PrimaryScreen.Bounds
Battery• GetSystemPowerStatusEx
Read the battery state
DEMO
Reacting to a changes
» Create an instance of the specific state» Register to the .Changes event» Implement your code
React to the battery state changes
DEMO
How we can use it (in a real world scenario)?
We can:» Disable buttons /menu when the battery strength
is low» Send data before battery goes down» …
MessagingMmsUnread
MessagingLastEmailAccountNameMessagingOtherEmailUnread
MessagingSmsUnread
MessagingVoiceMailTotalUnread
CalendarEventBusyStatus
ActiveSyncStatus
MediaPlayerTrackGenreMediaPlayerTrackTitle
MessagingActiveSyncAccountName
KeyboardPresent
OwnerNamePhoneActiveCallCount
PhoneCallCallingPhoneActiveDataCall
PhoneBlockedSim
PhoneCallBarring
PhoneCallForwardingOnLine1
ConnectionsVpnDescriptions
CradlePresent
ConnectionsCount
PhoneIncomingCallerContact
PhoneIncomingCallerContactPropertyName
DisplayRotation
Phone1xRttCoverage
PhoneGprsCoverage
HeadsetPresent
CameraPresent
ConnectionsProxyCount
PhoneMissedCall
PhoneMissedCalls
PhoneSimFull
PhoneIncomingCallerName
PhoneIncomingCallerNumber
MediaPlayerTrackArtist
MessagingTotalEmailUnreadPhoneLastIncomingCallerName
PhoneCallOnHold
WiFiStateConnected
WiFiStatePowerOn
WiFiStateNetworksAvailable
TasksActive
TasksHighPriority
Behind the scenes:
» The Windows Mobile Registry is the central repository:• SystemState: for the predefined states• RegistryState: for the custom state
Creating your own state:
» Crate an instance of the RegistryState Class» React to the changes like the classic SystemState
Create your own state
DEMO
Application Launcher
» Start an application when a monitored state changes
» StateBase implements IApplicationLaucher interface
» The IApplicationLaucher has the capability to start an application
» Information about the application to start are stored in the Registry
Application Launcher
DEMO
Remarks
» You can start directly when a state changes…SystemState monitoredState = new SystemState(SystemProperty.PowerBatteryBackupStrength);monitoredState.EnableApplicationLauncher("MyCoolApp");
The second application is not running before the state value doesn’t match with the criteria
…or when a state arrives to a specified valueSystemState monitoredState = new SystemState(SystemProperty.PowerBatteryBackupStrength);monitoredState.ComparisonType = StatusComparisonType.Less;monitoredState.ComparisonValue = BatteryLevel.Low;monitoredState.EnableApplicationLauncher("MyCoolApp");
In conclusion….
» Windows Mobile exposes more then 100 different states
» When you need to interact with any kind of system notifications, check the System States
» You can create your own state» Use the S&N API to produce a better software» Check out this open source application which
uses this APIs• http://www.codeplex.com/MobilePhoneAssistant
MessagingMmsUnread
MessagingLastEmailAccountNameMessagingOtherEmailUnread
MessagingSmsUnread
MessagingVoiceMailTotalUnread
CalendarEventBusyStatus
ActiveSyncStatus
MediaPlayerTrackGenreMediaPlayerTrackTitle
MessagingActiveSyncAccountName
KeyboardPresent
OwnerNamePhoneActiveCallCount
PhoneCallCallingPhoneActiveDataCall
PhoneBlockedSim
PhoneCallBarring
PhoneCallForwardingOnLine1
ConnectionsVpnDescriptions
CradlePresent
ConnectionsCount
PhoneIncomingCallerContact
PhoneIncomingCallerContactPropertyName
DisplayRotation
Phone1xRttCoverage
PhoneGprsCoverage
HeadsetPresent
CameraPresent
ConnectionsProxyCount
PhoneMissedCall
PhoneMissedCalls
PhoneSimFull
PhoneIncomingCallerName
PhoneIncomingCallerNumber
MediaPlayerTrackArtist
MessagingTotalEmailUnreadPhoneLastIncomingCallerName
PhoneCallOnHold
WiFiStateConnected
WiFiStatePowerOn
WiFiStateNetworksAvailable
TasksActive
TasksHighPriority
www.xedotnet.org 19
blog:
email:
web:
twitter:
Link
17/01/2008
Click icon to add picture
»Michele Locuratolo
http://www.michelelocuratolo.com
http://www.michelelocuratolo.com
Twitter.com/mighell