A method (500), a handheld electronic device (102) and an external
accessory (402) for controlling at least one function of a plurality of
functions of the handheld electronic device is provided. The method
includes determining (504) whether the handheld electronic device is
docked in an external accessory. Further, the method includes measuring
(506) a first magnetic field density when the handheld electronic device
is docked in the external accessory. Furthermore, the method includes
generating (508) a signal to activate at least one function, based on an
electrical parameter.