January 23, 2021
Hot Topics:

Getting Started with SIP in Android?, Page 2

  • By Lauren Darcey & Shane Conder
  • Send Email »
  • More Articles »

How Do I Get Started with SIP in Android?

You'll find all the SIP-related Android classes in the android.net.sip package. Within the Android scope, SIP communication begins with the SipManager class (android.net.sip.SipManager). The SipManager class is used to access SIP services, create sessions and verify connectivity. In order to create a SipSession (android.net.sip.SipSession), you're going to need to configure the Sip Profile for each call participant and tie it to the session. Once you've got your profile, you're ready to create the session and initiate a call or accept an incoming one.

How Do I Configure an Android SIP Profile?

Before you can communicate with others via SIP, each user needs a SIP account. There are lots of SIP account providers out there. Wikipedia lists a few. Asterisk, the PBX software, is compatible with SIP.

The Android SIP APIs include a class called SipProfile (android.net.sip.SipProfile), which you can use to configure a user's SIP account information. There's a helpful builder class to facilitate configuration called SipProfile.Builder (android.net.sip.SipProfile.Builder) that you may want to use.

How Do I Make an Audio Call Using the Android SIP APIs?

In brief, once you've got valid SipProfile instances for each end of a call, you can use the SipAudioCall class and the SipManager.makeAudioCall() method to initiate an audio call. All audio call details are then managed within the SipAudioCall class, including such things as startAudio() and sendDtmf() type commands. However, you don't make any such calls until after you receive the appropriate callbacks to your SipAudioCall.Listener class.

What About Other Types of SIP Communication, like Video?

While there's a helper class for audio calls, you can use the open() and close() methods of the SipManager class to initiate other types of SIP communication, like text or video sessions. You'll have to provide the bi-directional streaming, though.

How Do I Test My Android SIP Application?

You must test SIP features using a physical device; the Android emulator is not capable of emulating a SIP-based session. Therefore, you'll need a few SIP-aware Android devices running Android 2.3 or later, such as the Nexus One, Nexus S, and several other devices, for testing purposes.

Where Can I Find Sample Applications That Showcase the SIP APIs?

The Android guys and gals have included a sample application called SipDemo that is available for your review. The application is a simple audio-based walkie-talkie application using SIP. We suggest reviewing the application source code as it demonstrates SIP API best practices as well as how to configure your Android manifest file to support SIP and filter out devices that do not support SIP.


Beginning with Android 2.3 (API Level 9), developers can incorporate exciting internet telephony features into their Android applications using the Android SIP APIs. Testing SIP-based applications can be a little tricky, since you must test on physical devices. What types of SIP-based applications are you hoping to see developed in the near future? Are you thinking of developing one yourself? Let us know!

About the Authors

Shane Conder Shane Conder and Lauren Darcey--Contributing Editors, Mobile Development--have coauthored two books on Android development: an in-depth programming book entitled Android Wireless Application Development (ISBN-13: 978-0-321-62709-4) and Sams Teach Yourself Android Application Development in 24 Hours (ISBN-13: 978-0-321-67335-0). When not writing, they spend their time developing mobile software at their company and providing consulting services.

        Email        |        Blog        |        Twitter

Lauren Darcey

Originally published on https://www.developer.com.

Page 2 of 2

This article was originally published on August 30, 2011

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date