I have successfully integrated the Twilio SDK for Android, but when I try to make a call with it, it does not connect and does not show an error message in logcat, I get the following errors:
1) Failed to hangup call due to error code: 70015, message: pjsua_call_hangup(): Object already exists (PJ_EEXISTS) 2) Connection disconnected with error code 31000 and message Generic error this both errors occurs when i am calling disconnect method if i comment this method then my calling is working fine and i make call but if i call this method phone.disconnect(), i am getting error shown as above. This is my methods which i am using to make calls and to disconnect the calls.
////// Make calls
public void connect(String phoneNumber) { Map parameters = new HashMap(); parameters.put("PhoneNumber", phoneNumber); connection = device.connect(parameters, null ); if (connection == null) Log.w(TAG, "Failed to create new connection"); }
// Turn off the phone
public void disconnect() { if (connection != null) { connection.disconnect(); connection = null;
and in my OnClick event:
public void onClick(View view) { if (view.getId() == R.id.dialButton) Toast.makeText(getApplicationContext(), "Dialing...", Toast.LENGTH_LONG).show(); phone.connect("PHONE NUMBER"); if (view.getId() == R.id.hangupButton) Toast.makeText(getApplicationContext(), "Call Disconnected...", Toast.LENGTH_LONG).show(); phone.disconnect(); Please suggest me and help me because i tried all possible thing for hangout but still not able to solve it.Thanks in advance. ![enter image description here][1]
source share