gpt4 book ai didi

android - 无法让 SipDemo 注册 sip 语音通话

转载 作者:行者123 更新时间:2023-11-29 22:01:35 25 4
gpt4 key购买 nike

这几天我在尝试注册 sip 调用时遇到了问题。下面是我的代码,有人能告诉我 sip 注册中的问题是什么吗?

public class SipRegistration extends Activity {

public String sipAddress;
public SipManager manager = null;
public SipProfile profile = null;
public SipAudioCall call = null;
private EditText user, pass, domaine;
// private SipAudioCall.Listener listener;
protected static final String TAG = null;
private Button register;
private SipRegistrationListener listener;

@Override
public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);

getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
user = (EditText) findViewById(R.id.main_edtUser);
pass = (EditText) findViewById(R.id.main_edtPassword);
domaine = (EditText) findViewById(R.id.main_edtDomain);
register = (Button) findViewById(R.id.main_btnRegister);

register.setOnClickListener(new OnClickListener() {

public void onClick(View v) {
// TODO Auto-generated method stub
initializeLocalProfile();

}
});
}


/**
* Logs you into your SIP provider, registering this device as the location
* to send SIP calls to for your SIP address.
*
* @return
*/
public boolean initializeLocalProfile() {
if (manager == null) {
manager = SipManager.newInstance(this);
}

Log.e("On build profile.......", "");



String username = user.getText().toString();
String domain = domaine.getText().toString();
String password = pass.getText().toString();

if (username.length() == 0 || domain.length() == 0
|| password.length() == 0) {
return true;
}
Log.e("@@@@@@@@", "username \n" + username);
Log.e("@@@@@@@@@", "domain \n" + domain);
Log.e("@@@@@@@", "password \n" + password);

try {
SipProfile.Builder builder = new SipProfile.Builder(username,
domain);
builder.setPassword(password);
profile = builder.build();
Log.e("profile Password", "" + builder.build());

// Intent i = new Intent();
// i.setAction("android.SipDemo.INCOMING_CALL");
// PendingIntent pi = PendingIntent.getBroadcast(this, 0, i,
// Intent.FILL_IN_DATA);
// manager.open(profile, pi, null);
manager.open(profile);
Log.e("Profile:", "" + profile);
// Log.e("Intent:", "" + pi);

// Log.e("Listner:", "" + listener);
listener = new SipRegistrationListener() {

public void onRegistering(String localProfileUri) {
// TODO Auto-generated method stub
updateStatus("Registering with SIP Server...");
Log.e("Registration Running..........", "");
try {
manager.register(profile, 3000, listener);
} catch (SipException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}

public void onRegistrationDone(String localProfileUri,
long expiryTime) {
// TODO Auto-generated method stub

updateStatus("Ready");
Log.e("Registration Done..........", "");
}

public void onRegistrationFailed(String localProfileUri,
int errorCode, String errorMessage) {
// TODO Auto-generated method stub

updateStatus("Registration failed. Please check settings.");
Log.e("Registration failed..........", "");

}

};

if (manager.isRegistered(profile.getUriString())) {
Log.e("SipManager is ready for calls", "");
return true;
} else
return false;

} catch (Exception ex) {

Log.e("---Error-- initializeProfile: " + ex.getMessage(), "");
return false;

}

}

// This listener must be added AFTER manager.open is called,
// Otherwise the methods aren't guaranteed to fire.

public void updateStatus(final String status) {
// Be a good citizen. Make sure UI changes fire on the UI thread.
this.runOnUiThread(new Runnable() {
public void run() {
TextView labelView = (TextView) findViewById(R.id.main_sipLabel);
labelView.setText(status);
Log.e("Registration Running..........", "");
}
});
}
}

最佳答案

使用

将端口号更改为 8891
Sipmanger.port(); 

Sip 演示在真实设备 (2.3) 或更高版本上实际运行。确保在 list 文件中添加权限。

关于android - 无法让 SipDemo 注册 sip 语音通话,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11789343/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com