9

I am developing a application in android in which I want to send text message using sip/xmpp(session initiation protocol) can anyone give me code for it and any guidelines about its development and testing on any free sip provider.

Muhammad Hassan
  • 111
  • 2
  • 4
  • Why is SIP a requirement? Is it just that you want to send a text message without using the carrier? If that is the case you may want to look at SMSIfied [http://smsified.com/] which allows you to send and receive text messages via a REST API. It is free while it is in Beta and when it goes live it will be 1 cent per message. – Kevin Junghans Jul 06 '12 at 12:53
  • @User1479880 do you get Send textmessage via sip – Amitsharma Mar 31 '15 at 12:23

1 Answers1

-1

Update having re-read
Sorry, I failed to realise that the question related only to text messaging. SIP itself doesn't support text messaging, SIMPLE or MSRP extensions enable that. You need to find a stack that you are happy working with, here is one example Doubango and their demo product IMSDroid but Google 'Android MSRP' for plenty of other options. I still don't know anything about XMPP,but check out this thread for a great list of libraries and uses.
End update

What have you tried so far? For the SIP (voice) part of your question here is the documentation on the Android Developers site with all you need to know and here is a free SIP provider: Getonsip.

Reduced code sample, largely lifted from Android developer site.

Essentially you need to make sure minSDK is set to 9 as the SIP library was not added until 2.3. Add the services to your manifest:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.USE_SIP" />

Optionally add the uses-feature voip directive if you want your app to not install on devices where it will not work.

<uses-feature android:name="android.hardware.sip.voip" />

Create a SipManager:

android.net.sip.SipManager manager = SipManager.newInstance(this);

Create a profile with which to make/receive calls through your provider:

android.net.sip.SipProfile.Builder builder = new SipProfile.Builder(username, domain);
builder.setPassword(password);
android.net.sip.SipProfile sipProfile = builder.build();

If all you care about is making calls:

manager.open(profile);

To make a call you u work with a listener:

SipAudioCall.Listener listener = new SipAudioCall.Listener() {

    @Override
    public void onCallEstablished(SipAudioCall call) {
        call.startAudio();
        call.setSpeakerMode(true);
        call.toggleMute();
        ...
    }

    @Override
    public void onCallEnded(SipAudioCall call) {
        // Do something.
    }
};

Now, as long as you have the SIP address of your peer you can use:

SipProfile friendProfile = ...;
manager.makeAudioCall(sipProfile.getUriString(), friendAddress, listener, 30);

That should get you started. Unfortunately I have no experience with XMPP.

Community
  • 1
  • 1
JohnMark13
  • 3,709
  • 1
  • 15
  • 26