cesky english
  Symbian   Travels
Symbian (Applications)

 The Wall
Symbian (Examples)

HeadSet Monitor
 HeadSet Monitor

Platform: Series 60 (Symbian)



Tested on: Siemens SX1

Should also work on: It is probably only feature supported on SX1.
(If you run this game on one of these phones please send me an email so I can mark this phone as supported.)


Some time ago, there was a discussion on Siemens Developer Portal about the possibility to check the status of Headset on SX1 phone. This phone has one nice feature and that is FM radio. When you want to use it you need antenna that is at the same time headset (or the other way around..:-) Back then question was: is it possible to monitor plug-in and removal of the headset? Answer is: yes it is possible and in this article I will explain how.

It is surprisingly easy and difficult at the same time. Easy because we can use standard system agent and difficult because it takes some mocking around to find out the proper IDs that are necessary to set the observer.

As I said we will be using System Agent so "LIBRARY sysagt.lib" must be added to our .mmp file, and "#include " must be included in the file where we want to use SA functionality.

RSystemAgent iSystemAgent;
TSysAgentEvent iSysAgentEvent;

OK. This was the easy part. The difficult one comes now. But as I already found the information for you it is not difficult any more..:-)

We will define the proper UID to be able to subscribe to this system event. And I also included the enumeration of possible values we can receive.

const TInt KUidHeadsetStatusInt = 0x100052D5;
const TUid KUidHeadsetStatusUid = {KUidHeadsetStatusInt};

enum TSAHeadsetStatus

Our observer class will be inherited from CActive and implement all the necessary methods. At the beginning lets connect to SA.


Active Object must be started and so we issue this series of commands

iSysAgentEvent.SetRequestStatus( iStatus );

iSysAgentEvent.SetUid( KUidHeadsetStatusUid );

iSystemAgent.NotifyOnEvent( iSysAgentEvent );


Now we just wait in RunL() for the system to announce a change

TInt newStatus( iSystemAgent.GetState( KUidHeadsetStatus ) );

And that is it. Just don't forget to close the connection to SA in destructor - iSystemAgent.Close();

At the end just one small remark. This application was written for Siemens SX1 phone and tested on it. I have no clue if it works on some other devices as I don't have headset for any of them and so cannot test it.

design, programming: Tomas Kucera (2002)
e-mail: sopta (at) post.cz, icq: 33297193
last change: 2005/01/29