0
我想實現我自己的android sip實現,並且遇到註冊到我的SIP服務器的問題。特別是,SipManager.register()函數拋出一個NullPointerException。有沒有人經歷過這個?在下面的函數中沒有任何內容是空的,所以我不明白這是從哪裏來的。謝謝Android SipManager拋出NullPointException
public boolean initializeProfile() {
final Globals global = Globals.getInstance();
if (sipProfile != null)
closeLocalProfile();
String username = "omitted";
String password = "omitted";
String server = "omitted";
try {
global.Log("Trying to build the profile");
SipProfile.Builder builder = new SipProfile.Builder(username,
server);
builder.setPassword(password);
sipProfile = builder.build();
builder.setAutoRegistration(true);
sipManager.open(sipProfile);
SipRegistrationListener listener = new SipRegistrationListener() {
public void onRegistering(String localProfileUri) {
global.Log("Sip Listener- Attempting to Register");
}
public void onRegistrationDone(String localProfileUri,
long expiryTime) {
global.Log("Sip Listener- Registration Success!");
}
public void onRegistrationFailed(String localProfileUri,
int errorCode, String errorMessage) {
global.Log("Sip Listener- Registration Failed");
}
};
sipManager.setRegistrationListener(sipProfile.getUriString(), listener);
//THIS IS WHERE THE EXCEPTION IS BEING THROWN
sipManager.register(sipProfile, 3000, listener);
if (sipManager.isRegistered(sipProfile.getUriString()))
{
global.Log("SipManager is ready for calls");
return true;
}
else
return false;
} catch (Exception ex) {
global.Log("---Error-- initializeProfile: " + ex.getMessage());
return false;
}
}