19
Real World State and Notification Broker » Michele Locuratolo In collaborazione con

Real World State And Notification Broker

Embed Size (px)

Citation preview

Page 1: Real World State And Notification Broker

Real World State and Notification Broker

» Michele Locuratolo

In collaborazione con

Page 2: Real World State And Notification Broker

Agenda

» What is the State and Notification Broker» Reading a System State» Reacting to changes» Application launcher

Page 3: Real World State And Notification Broker

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

Page 4: Real World State And Notification Broker

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)

Page 5: Real World State And Notification Broker

A BIG difference

todayScreen• SystemProperty.DisplayRotation

Battery• SystemProperty.PowerBatteryStrength

yesterday

Screen:• GetSystemMetrics • Screen.PrimaryScreen.Bounds

Battery• GetSystemPowerStatusEx

Page 6: Real World State And Notification Broker

Read the battery state

DEMO

Page 7: Real World State And Notification Broker

Reacting to a changes

» Create an instance of the specific state» Register to the .Changes event» Implement your code

Page 8: Real World State And Notification Broker

React to the battery state changes

DEMO

Page 9: Real World State And Notification Broker

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» …

Page 10: Real World State And Notification Broker

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

Page 11: Real World State And Notification Broker

Behind the scenes:

» The Windows Mobile Registry is the central repository:• SystemState: for the predefined states• RegistryState: for the custom state

Page 12: Real World State And Notification Broker

Creating your own state:

» Crate an instance of the RegistryState Class» React to the changes like the classic SystemState

Page 13: Real World State And Notification Broker

Create your own state

DEMO

Page 14: Real World State And Notification Broker

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

Page 15: Real World State And Notification Broker

Application Launcher

DEMO

Page 16: Real World State And Notification Broker

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");

Page 17: Real World State And Notification Broker

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

Page 18: Real World State And Notification Broker

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

Page 19: Real World State And Notification Broker

www.xedotnet.org 19

blog:

email:

web:

twitter:

Link

17/01/2008

Click icon to add picture

»Michele Locuratolo

http://www.michelelocuratolo.com

[email protected]

http://www.michelelocuratolo.com

Twitter.com/mighell