Search Tutorials


Friday, 19 June 2015

Android Linphone source code tutorial - Part 2

I have published first part of Android Linphone SDK integration already. In this tutorial, I am going to share source code modification tips and overview of Linphone project code. Before reading this post, check Android Linphone SDK Tutorial - Part 1. Linphone project's packages and source code can be changed at any time but I am going to share details of Linphone project which I have currently.

Android Linphone Tutorial

Note:- Some PPTs are available on my slideshare account related to android linphone project.


Basic overview of important packages is give below:-

1. org.linphone : This package has mostly all activities, fragments and important manager classes. Easily understandable by class name which class what will do.

2. org.linphone.compatibility : This package has compatibility classes for each android API level. To use notifications and gestures in different android versions.

3. org.linphone.gcm : This package has GCM service classes. Linphone uses SIP server for Push notifications to show chat, video call, etc. notification.

4. org.linphone.setup : This package has account setup classes. To register, login or manage user account.

5. org.linphone.ui : This package has user interface's widget classes. To manage action on widgets like call button, erase button, number button, on scrolling, on sliding drawer, etc.


Now I am going to share some useful classes and codes:-

1. LinphoneCore : The LinphoneCore is the root for all liblinphone operations. You need only one per application.

LinphoneCore lc = LinphoneCoreFactory.instance().createLinphoneCore(listener, context)

listener(LinphoneCoreListener) - listener to receive notifications from the core.
context - an application context, on android this MUST be the android.content.Context object used by the application.

Throws: LinphoneCoreException

about listener class: create a class and implement LinphoneCoreListener and make an object "listener" and pass it.

you can also create it simply by using LinphoneManager in Linphone project:

LinphoneCore lc=LinphoneManager.getLc();

2. How to set/get register user details?

LinphonePreferences : This class uses setter and getter method for user info and every method is easily understandable.

LinphonePreferences mPrefs = LinphonePreferences.instance();

To get default user index:

int account_index=mPrefs.getDefaultAccountIndex();
String user_name=mPrefs.getAccountUsername(account_index);

now using default account index, we can set or get user details easily.

3. How to initiate/terminate/accept call on a sip address?

LinphoneManager.getInstance().newOutgoingCall(AddressType address);
LinphoneManager.getInstance().newOutgoingCall(String to, String displayName);

Address/to can be user_name or beacuse interpretUrl(String to) method converts string to LinphonAddress(SIP Address). InterpretUrl is a method of LinphoneCore class.

To terminate call, use:-


To check current call status(After State than write dot than press CTRL+SHIFT for all other options) in any class:-


where lc is LinphoneCore object.

If you implement LinphoneCoreListener in any class(as has) than the below method will call on every change in call status:-

public void callState(final LinphoneCore lc,final LinphoneCall call, final State state, final String message)
  //code here

To accept call:-

lc.acceptCall(aCall) // lc is LinphoneCore object & aCall is LinphoneCall object.

4. How to send/recieve chat message?

To send message, pass destination sip address as parameter:

LinphoneChatRoom chat_room = lc.createChatRoom(""); //lc is object of LinphoneCore
chat_room.sendMessage("Hello world");

To receive chat message, Implement LinphoneCoreListener in your class(as
has) and textReceived method will call when you got message from someone.

void textReceived(LinphoneCore lc, LinphoneChatRoom cr,LinphoneAddress from,String message) {
//write code here to display message on gui.

5. How to add video call support in running audio call?

//Obtain reference of current call
LinphoneCall lCall = lc.getCurrentCall(); //lc is LinphoneCore object

//Obtain configuration parameter copy for current call
LinphoneCallParams params = lCall.getCurrentParamsCopy();

//Enable video

//Initiate reInvite
lc.updateCall(lCall, params);

For more download excel sheet of Linphone notes(Check all tabs of excel sheet) and check official document.

Related Programs:-

Start Working on Linphone Android

Add Google AdMob Ads in Android App & Earn Money

Add Facebook SDK in Android Application

Android Twitter Fabric SDK Integration with user details in Android Studio

Advance Android Google Map 2 Tutorial with Examples - Part 1


  1. in linphonerc_default (sample/res/raw) , I want to test a few samples. However, in readme it says:
    config-uri=INSERT_URL_TO_CONFIG_TO_TRY_HERE" which URL do I need to specify? thanks

  2. This comment has been removed by a blog administrator.

  3. Thanks, really informative. Would like if a simple video call example can be shown

    1. After set-up this project, you can call and chat. This is embedded in project already.

  4. Where is linphone.core package in that sample code???That package is missing

    1. Hi, I am not aware of new changes in Linphone. May be they changed packages.

  5. Is there any method for message seen in Linphone?

  6. How to create LinphoneConferenceParams in android?

    1. Hi Sheena, This is an interface and you have to implement it to use methods of this interface. As I saw your question on stack-overflow. First make LinphoneCore object using: LinphoneCore lc=LinphoneManager.getLc(); than use: lc.createConference(this);

    2. Thank you Mohsin, but i got error with this code,
      lc.createConference(this); I got error here , they recommended Linphoneconferenceparams instead of context

    3. Try this:-
      lc.createConference(new Linphoneconferenceparams(){

    4. Thank you Mohsin, Now i have an another issue
      when i call this method
      chatRoom = lc.getOrCreateGroupChatRoom(groupName, groupMembers, groupSize, 0, 0);

      i got an error

      UnsatisfiedLinkError: No implementation found for long org.linphone.core.LinphoneCoreImpl.getOrCreateGroupChatRoom(long, java.lang.String, java.lang.String[], int, int, int) (tried Java_org_linphone_core_LinphoneCoreImpl_getOrCreateGroupChatRoom and Java_org_linphone_core_LinphoneCoreImpl_getOrCreateGroupChatRoom__JLjava_lang_String_2_3Ljava_lang_String_2III)

  7. I'm not getting the idea as you described. Stuck in Linphone Core. Help me. !

  8. Hi,
    I've cloned Linphone source from git:// and library from Linphone SDK from

    I'm using Android Studio on Windows to open the project. I've correctly unzipped the library files to the /libs directory. But there is an error message on many of the source files on this import:


    Error: cannot resolve symbol tools.

    It seems that the liblinphone.jar file is missing the package tools

    Any help would be greatly appreciated


back to top