Open robertstrz opened 6 years ago
Hi @gotev, I am getting the same error when I am going to register a sip account. Please, can you give any hints to solve the issue?
I also have the same problem. you found the solution
which version? tried the latest?
this sip client works with asterisk pbx ? because my pbx is asterisk
which version? tried the latest? I use the latest version
which version? tried the latest?
here is my code
public class fofe extends Activity {
private int port= 5061;
private String realm="192.168.1.197";
private String name="300";
private String password="poseidon";
private String numberToCall="sip:301@192.168.1.197";
private static final String KEY_SIP_ACCOUNT = "sip_account";
private SipAccountData mSipAccount;
private BroadcastEventReceiver sipEvents = new BroadcastEventReceiver() {
@Override
public void onRegistration(String accountID, pjsip_status_code registrationStateCode) {
if (registrationStateCode == pjsip_status_code.PJSIP_SC_OK) {
Toast.makeText(fofe.this, "Registered", Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(fofe.this, "Unregistered", Toast.LENGTH_SHORT).show();
}
}
@Override
public void onReceivedCodecPriorities(ArrayList<CodecPriority> codecPriorities) {
for (CodecPriority codec : codecPriorities) {
if (codec.getCodecName().startsWith("PCM")) {
codec.setPriority(CodecPriority.PRIORITY_MAX);
} else {
codec.setPriority(CodecPriority.PRIORITY_DISABLED);
}
}
SipServiceCommand.setCodecPriorities(fofe.this, codecPriorities);
}
};
@Override
protected void onSaveInstanceState(Bundle outState) {
if (mSipAccount != null) {
outState.putParcelable(KEY_SIP_ACCOUNT, mSipAccount);
}
super.onSaveInstanceState(outState);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fofe);
Logger.setLogLevel(Logger.LogLevel.DEBUG);
if (savedInstanceState != null && savedInstanceState.containsKey(KEY_SIP_ACCOUNT)) {
mSipAccount = savedInstanceState.getParcelable(KEY_SIP_ACCOUNT);
}
onRegister();
}
@Override
protected void onPause() {
super.onPause();
sipEvents.unregister(this);
}
@Override
protected void onResume() {
super.onResume();
sipEvents.register(this);
}
public void onRegister() {
mSipAccount = new SipAccountData();
mSipAccount.setHost("192.168.1.197")
.setPort(port)
.setTcpTransport(true)
.setUsername(name)
.setPassword(password)
.setRealm(realm);
SipServiceCommand.setAccount(this, mSipAccount);
SipServiceCommand.getCodecPriorities(this);
}
public void onCall() {
if (mSipAccount == null) {
Toast.makeText(this, "Add an account and register it first", Toast.LENGTH_LONG).show();
return;
}
String number = numberToCall;
if (number.isEmpty()) {
number = "301";
//Toast.makeText(this, "Provide a number to call", Toast.LENGTH_SHORT).show();
//return;
}
SipServiceCommand.makeCall(this, mSipAccount.getIdUri(), number);
}
public void onTerminate() {
SipServiceCommand.hangUpActiveCalls(this, mSipAccount.getIdUri());
}
}
git it! you need to pur the contactUriParams
in your account, unfortunately I haven't initializaed it as a default empty string, thus it fails. As a workaround you can call .setContactUriParams("");
on your sipAccount
like this ? mSipAccount.setHost("192.168.1.197") .setPort(port) .setTcpTransport(true) .setUsername(name) .setPassword(password) .setRealm(realm) .setContactUriParams("")
i did it, the problem is not solved here is my code : https://github.com/jojupiter/wiaCall
please help me
but the app was crashing at that point. Did you get a different error?
like this ? mSipAccount.setHost("192.168.1.197") .setPort(port) .setTcpTransport(true) .setUsername(name) .setPassword(password) .setRealm(realm) .setContactUriParams("")
i did it, the problem is not solved here is my code : https://github.com/jojupiter/wiaCall
please help me
like this ? mSipAccount.setHost("192.168.1.197") .setPort(port) .setTcpTransport(true) .setUsername(name) .setPassword(password) .setRealm(realm) .setContactUriParams("")
i did it, the problem is not solved here is my code : https://github.com/jojupiter/wiaCall
please help me
I have encountered similar problems. Have you solved your problem? Can you help me?
It's working for me. I use realm same as host. And call id is string not int in sipAccount i think
Hello, I was trying to run the demo app but unfortunatelly I was unable to connect to my sip server. I have also tried with the data provided in demo app and I have also received the same NullPointException (it comes from the pjsip library also application does not crush)