从 Android SIP Class 调用 SipProfile.Builder 时未处理的异常
Unhandled Exception when calling SipProfile.Builder from Android SIP Class
创建Builder对象时出错。这是我的代码:
SipProfile.Builder builder = new SipProfile.Builder("address","username");
错误::
unhandled exception: java.text.ParseException
这是来自 Android 参考的示例。:
public SipProfile mSipProfile = null;
...
SipProfile.Builder builder = new SipProfile.Builder(username, domain);
builder.setPassword(password);
mSipProfile = builder.build();
http://developer.android.com/guide/topics/connectivity/sip.html#manager
问题是,SipProfile.Builder 可能会在运行时失败。这取决于服务器而不是代码。那么我们应该始终将它与 try-catch 块一起使用。
这是工作代码:
try {
String id = txtId.getText().toString();
String username = txtUsername.getText().toString();
SipProfile.Builder builder1 = new SipProfile.Builder(id, username);
}
catch(java.text.ParseException e){
e.printStackTrace();
}
创建Builder对象时出错。这是我的代码:
SipProfile.Builder builder = new SipProfile.Builder("address","username");
错误::
unhandled exception: java.text.ParseException
这是来自 Android 参考的示例。:
public SipProfile mSipProfile = null;
...
SipProfile.Builder builder = new SipProfile.Builder(username, domain);
builder.setPassword(password);
mSipProfile = builder.build();
http://developer.android.com/guide/topics/connectivity/sip.html#manager
问题是,SipProfile.Builder 可能会在运行时失败。这取决于服务器而不是代码。那么我们应该始终将它与 try-catch 块一起使用。 这是工作代码:
try {
String id = txtId.getText().toString();
String username = txtUsername.getText().toString();
SipProfile.Builder builder1 = new SipProfile.Builder(id, username);
}
catch(java.text.ParseException e){
e.printStackTrace();
}