2013-03-07 4 views
1

Я сделал много R & D при получении входящего номера при вызове выполняется из номера Twilio в другое количество Twilio в приложении с помощью Twilio в качестве сторонней интеграции ,Как получить входящий номер от twilio стороннего API

Но у меня ничего не получается относительно этого входящего номера, я получил звонок от другого номера Twilio, устройство прослушивает входящий звонок, но не может определить входящий номер, потому что я использую этот метод connectionCall.IncomingParameterFromKey, он возвращает меня только «От».

Ниже приведен код для приема вызова в приложении с использованием интеграции Twilio.

public class Call_Answer extends Activity implements OnClickListener{ 

String sub_sid="",sub_auth_token="",call_from=""; 
SharedPreferences sharedPref; 
SharedPreferences.Editor prefEdit; 
TextView callanswer_btn,callreject_btn; 
private Connection connectionCall; 
IncomingCall phone; 
private Device device; 

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    // Method onCreate created by vk hooda on Oct 30, 2012 
    super.onCreate(savedInstanceState); 
    requestWindowFeature(Window.FEATURE_NO_TITLE); 
    setContentView(R.layout.callanswer); 


    sharedPrefValues(); 
    initializeView(); 

} 

private void sharedPrefValues() { 
    // Method sharedPrefValues created by vk hooda on Oct 31, 2012 


    sharedPref=PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); 
    prefEdit=sharedPref.edit(); 
    sub_sid=sharedPref.getString(Constant_Variables.using_sub_sid,""); 
    sub_auth_token=sharedPref.getString(Constant_Variables.using_sub_auth_token,""); 
    call_from=sharedPref.getString(Constant_Variables.using_phone_number, ""); 

    //Initialize Calls 
    phone=new IncomingCall(sub_sid,sub_auth_token,call_from,getApplicationContext()); 

    //phone=new IncomingCall(Constants.account_SID,Constants.account_Token,Constants.karl_number,getApplicationContext()); 

} 

private void initializeView() { 
    // Method initializeView created by vk hooda on Oct 30, 2012 

    callanswer_btn=(TextView)findViewById(R.id.callanswer_btn); 
    callreject_btn=(TextView)findViewById(R.id.callreject_btn); 

    callanswer_btn.setOnClickListener(this); 
    callreject_btn.setOnClickListener(this); 
} 

@Override 
public void onNewIntent(Intent intent) 
{ 
    super.onNewIntent(intent); 
    setIntent(intent); 
} 

@Override 
public void onResume() 
{ 
    super.onResume(); 

    Intent intent = getIntent(); 
    Device device = intent.getParcelableExtra(Device.EXTRA_DEVICE); 
    Connection connection = intent.getParcelableExtra(Device.EXTRA_CONNECTION); 
    if (device != null && connection != null) { 
     intent.removeExtra(Device.EXTRA_DEVICE); 
     intent.removeExtra(Device.EXTRA_CONNECTION); 
     handleIncomingConnection(device, connection); 

     //    ringingPhone(intent); 

    } 
} 

public void handleIncomingConnection(Device inDevice, Connection inConnection) 
{ 
    Log.i("Handle incoming call", "Device received incoming connection"); 
    connectionCall=inConnection; 
    device=inDevice; 
    if (connectionCall != null) 
    { 
     connectionCall.disconnect(); 
     connectionCall = inConnection; 
//   connectionCall.reject(); 


     Log.i("Blocktimer.blocking_call",""+Blocktimer.blocking_call); 

     if(Blocktimer.blocking_call == true) 
     { 
      connectionCall.reject(); 
      Blocktimer.blocking_call = false; 
     } 



     Log.i("connectionIIIIII",""+ connectionCall.IncomingParameterAccountSIDKey); 
     Log.i("connectionIIIIII",""+ connectionCall.IncomingParameterAPIVersionKey); 
     Log.i("connectionIIIIII",""+ connectionCall.IncomingParameterCallSIDKey); 
     Log.i("connectionIIIIII",""+ connectionCall.IncomingParameterFromKey); 
     Log.i("connectionIIIIII",""+ connectionCall.IncomingParameterToKey); 
     Log.i("connectionIIIIII",""+ connectionCall.hashCode()); 
     Log.i("connectionIIIIII",""+ connectionCall.CONTENTS_FILE_DESCRIPTOR); 
     Log.i("connectionIIIIII",""+ connectionCall.PARCELABLE_WRITE_RETURN_VALUE); 
     Log.i("connectionIIIIII",""+ connectionCall.getState()); 
     Log.i("connectionIIIIII",""+ connectionCall.isIncoming()); 
     Log.i("connectionIIIIII",""+ connectionCall.isMuted()); 




     Log.v("Handling Incoming Call","Someone calling you.you have accepted it here."); 
    } 

} 

public void onClick(View v) { 
    // Method onClick created by vk hooda on Oct 30, 2012 

    if(v==callanswer_btn) 
    { 

     if (connectionCall != null) 
     { 
      connectionCall.accept(); 
      Log.i("connectionaccept",""+ connectionCall.getState()); 
      Log.v("calling answer","Conversation start....."); 
     } 
    } 

    if(v==callreject_btn) 
    { 
     //connectionCall.disconnect(); 
     Log.v("calling disconnect","Conversation disconnect....."); 

     if (connectionCall != null) 
     { 
      connectionCall.disconnect(); 
      Log.i("connectionReject",""+ connectionCall.getState()); 
      connectionCall=null; 

      Log.v("Disconnect","Disconnecting in finalize method"); 
     } 
     if (device != null) 
     { 
      Log.v("Disconnect","Release in finalize method"); 
      device.release(); 
      device=null; 
     } 

     finish(); 
    } 
} 

}

ответ

0

я также столкнулась с той же проблемой, и я выпрямляется с помощью этого кода connection.IncomingParameterFromKey будет возвращает вам имя параметра только нужно, чтобы передать это имя параметров соединения.

код:.

connection.getParameters() получаем (connection.IncomingParameterFromKey) .Надеть ("% 2B", "");

Смежные вопросы