Android で利用可能なネイティブ Sip ライブラリを使用してアプリを開発しています。これが私のコードです
package com.example.demosip;
import java.text.ParseException;
import android.net.sip.SipAudioCall;
import android.net.sip.SipException;
import android.net.sip.SipManager;
import android.net.sip.SipProfile;
import android.net.sip.SipRegistrationListener;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.app.Activity;
import android.app.PendingIntent;
import android.content.Intent;
import android.util.Log;
import android.view.Menu;
public class CopyOfSipMainActivty2 extends Activity {
SipManager sipM;
SipProfile sipP;
SipProfile.Builder builder;
SipAudioCall.Listener listener;
@
Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sip_main_activty);
if (sipM == null) {
sipM = SipManager.newInstance(this);
try {
builder = new SipProfile.Builder("ABC", "123.123.123.1");
} catch (ParseException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
builder.setPassword("ABC");
builder.setPort(5060);
sipP = builder.build();
//register
Intent intent = new Intent();
intent.setAction("android.SipDemo.INCOMING_CALL");
PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, intent, Intent.FILL_IN_DATA);
try {
sipM.open(sipP, pendingIntent, null);
} catch (SipException e) {
e.printStackTrace();
}
}
}@
Override
protected void onStart() {
// TODO Auto-generated method stub
super.onStart();
}@
Override
protected void onResume() {
// TODO Auto-generated method stub
try {
sipM.setRegistrationListener(sipP.getUriString(), new SipRegistrationListener() {
@
Override
public void onRegistrationFailed(String localProfileUri, int errorCode,
String errorMessage) {
Log.e("registration failed", "registration failed");
// TODO Auto-generated method stub
}@
Override
public void onRegistrationDone(String localProfileUri, long expiryTime) {
// TODO Auto-generated method stub
Log.e("registration done", "registration done");
}@
Override
public void onRegistering(String localProfileUri) {
// TODO Auto-generated method stub
Log.e("registring", "registring");
}
});
listener = new SipAudioCall.Listener() {
@
Override
public void onCallEstablished(SipAudioCall call) {
Log.e("inside listener ", "call established");
call.startAudio();
call.setSpeakerMode(true);
call.toggleMute();
}@
Override
public void onCallEnded(SipAudioCall call) {
Log.e("inside listener ", "call ended");
// Do something.
}
};
} catch (SipException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
new CountDownTimer(5 * 1000, 1000) {
@
Override
public void onTick(long millisUntilFinished) {
Log.e("on tick", "on tick ");
}
@
Override
public void onFinish() {
try {
Log.e("on finish", "calling nummber");
sipM.makeAudioCall(sipP.getUriString(), "91 XXXXXXXXXX", listener, 1000 * 20);
} catch (SipException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}.start();
super.onResume();
}
}
しかし、電話をかけると、ログに行が出力されます
このエラーが発生しています:
sip session error: CLIENT_ERROR: libcore.io.GaiException: getaddrinfo failed: EAI_NODATA (No address associated with hostname)
10-05 11:33:14.660: D/SipAudioCall(6864): stop audiocall
私はそれに慣れていないので、問題が見つかりません。また、 LIB FOR INTEGRATING SIP IN ANDROID PROVIDED BY SIPDROIDのようなライブラリもいくつか持っています。
このライブラリの使用方法に関する適切なドキュメントがまだありません。