7.6. Telephone Functionality and Contacts

The telephone module provides an API to the telephone functionality of the mobile phone, so it is possible to use a mobile phone as a phone! Compared to many other modules in this book, the telephone module is particularly simple.

The module includes only two functions: telephone.dial() and telephone.hang_up(). The dial() function accepts a telephone number as a string, as it may contain special characters, such as the plus sign. Note that if there is an call in process when the dial() function is called, the previous call is put on hold and a new call is established.

Example 7.10. Telephone
import telephone, e32

telephone.dial('+1412345602')
e32.ao_sleep(10)
telephone.hang_up()

If you start recording sound when a call is active, the phone call is recorded. See Example 26 for a simple sound recorder that can easily be combined with the telephone module. Ethical implications are left as an exercise for the reader.

The contacts module offers an API to the phone's address book. Although in the simplest form the address book could be a dictionary, which has names as keys and phone numbers as values, the modern mobile phone provides a sophisticated database which can handle rich forms of contact information. Correspondingly, the contacts module includes an extensive set of functions and objects that hook into the underlying contacts service that is provided by the operating system.

The PyS60 API documentation contains a detailed description ...

Get Mobile Python: Rapid Prototyping of Applications on the Mobile Platform now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.