Registering with the server through SipRegisterationListener()Every user has an Account+DialplanDialplan: what happens when this extension is calledCreating accounts1 user to 1 extensionSimple Generic DialplanCentral DBIntercepting a callAsterisk Server: Configuration FilesIn order to be able to receive a call we need to use intentsWHAT IS AN INTENT?IntentsIt's a facility that provides the android activity to launch another activity.When the SIP service receives a new call, it sends out an intent with the action string provided by the application. In SipDemo, this action string is android.SipDemo.INCOMING_CALL.Setting the action which will be used by an intent filter when the device receives a call:

Intent intent = new Intent();intent.setAction("android.SipDemo.INCOMING_CALL");PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, Intent.FILL_IN_DATA);mSipManager.open(mSipProfile, pendingIntent, null);Broadcast ReceiverAndroid component which allows you to register for application events. All registered receivers for an event will be notified as soon as this event happens.Intent FilterIntentFilter filter = new IntentFilter();

Filtering a particular action

filter.addAction("android.SipDemo.INCOMING_CALL"); callReceiver = new IncomingCallReceiver(); this.registerReceiver(callReceiver, filter);Creating an intent filter In AndroidManifest.xml, declare a <receiver>. In SipDemo, this is <receiver android:name=".IncomingCallReceiver" android:label="Call Receiver"/>.Implement the receiver, which is a subclass of BroadcastReceiver. In SipDemo, this is IncomingCallReceiver.Initialize the local profile (SipProfile) with a pending intent that fires your receiver when someone calls the local profile.Set up an intent filter that filters by the action that represents an incoming call. In SipDemo, this action is android.SipDemo.INCOMING_CALL.Intercepting a call IIpublic SipManager mSipManager = null;...if(mSipManager == null) { mSipManager = SipManager.newInstance(this);}The function of the Intent filter is to intercept that broadcast which will then fire the IncomingCallReceiver

We'll use intent filters in order to be notified by a broadcast once an incoming call arrives. IncomingCallReceiver has to extend BroadCastReceiverMaking a CallIn order to place a call, we need to set up a listenerSipAudioCall.Listener listener = new SipAudioCall.Listener()

sipProfile = caller's sip profilesipAddress = address of the calleelistener = sip listener 30 = timeout SIP Profile (Registration)To complete the registration phase, we need to set a SipRegistrationListener on the SipManager, in order to determine whether the sipProfile was successfully registered with the SIP provider (server)

Contacting the API Transactions between the server and the application are basically carried out through http requests (POST and GET)POST: used if we want to modify something in the server e.g Insert data in the database table

GET: used if we want to retrieve information from the server, e.g querying the database for instance.

POST requestIn order to save the phone number with which the user signed upwe need to insert said phone number in the database table.

First we need to create an httpClient in order to perform such a request httpclient = new DefaultHttpClient();

Second, specify the address of the API service that the application will send the data to httppost = new HttpPost("http://localhost/ziko/index.php");

POST request IIIn order to send the data we need to encapsulate it in a Name Value Pair arraylist nameValuePairs = new ArrayList<NameValuePair>(); nameValuePairs.add(new BasicNameValuePair("Phone Number", phoneNo));

httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));

response = httpclient.execute(httppost);

Response will have the value of the server response after executing the httppost.

If the response's status line is 200, then that means the post was successful.

GET request URL of the API Service String getURL = "http://localhost/ziko/CheckNumber.php?number="+number;

Initializing a get request HttpGet get = new HttpGet(getURL);

HttpResponse responseGet = client.execute(get); HttpEntity resEntityGet = responseGet.getEntity(); The server checks the number one by one and sends a response very much like the post response, except here it either sends true or false, true being that the server was successful in finding the phone number the application just sent in its database table.

Easier acces to asterisk serverStatic IP that can be addressed from networkSolid solution for server virtualization Uses SSH client to connect to the linux based machineIn order to access our server we typessh root@'static ip'ConclusionRecap: Feasible replicationOpen source alternatives in the market Setting up the pbx is the first and biggest step in any voip (Many free sip clients are available in the market)