Java 从Android SIP类调用SipProfile.Builder时发生未处理的异常
创建生成器对象时出错。这是我的代码:Java 从Android SIP类调用SipProfile.Builder时发生未处理的异常,java,android,object,android-studio,compiler-errors,Java,Android,Object,Android Studio,Compiler Errors,创建生成器对象时出错。这是我的代码: SipProfile.Builder builder = new SipProfile.Builder("address","username"); 错误:: 未处理的异常:java.text.ParseException 这是Android参考中的一个示例: public SipProfile mSipProfile = null; ... SipProfile.Builder builder = new SipProfile.Builder(user
SipProfile.Builder builder = new SipProfile.Builder("address","username");
错误::
未处理的异常:java.text.ParseException
这是Android参考中的一个示例:
public SipProfile mSipProfile = null;
...
SipProfile.Builder builder = new SipProfile.Builder(username, domain);
builder.setPassword(password);
mSipProfile = builder.build();
问题是,SipProfile.Builder在运行时可能会失败。这取决于服务器,而不是代码。然后,我们应该始终将其与try-catch-block一起使用。 这是工作代码:
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();
}