在类扩展线程内的 sipmanger.open 之后调用以下内容。我检查了是否有任何参数为空,而它们不是。
有任何想法吗 ?
private void setlisten() throws SipException {
sipman.setRegistrationListener(sipprofile.getUriString(), new SipRegistrationListener() {
public void onRegistering(String localProfileUri) {
Message msg = Message.obtain();
msg.what = 10;
}
public void onRegistrationDone(String localProfileUri, long expiryTime) {
Message msg = Message.obtain();
msg.what = 93;
Log.d("register", "register done");
}
public void onRegistrationFailed(String localProfileUri, int errorCode,String errorMessage) {
}
});
}
堆栈跟踪如下:
f09-26 16:24:03.457: E/AndroidRuntime(11692): FATAL EXCEPTION: Thread-11
09-26 16:24:03.457: E/AndroidRuntime(11692): java.lang.NullPointerException
09-26 16:24:03.457: E/AndroidRuntime(11692): at com.example.project2.sipwork.setlisten(sipwork.java:153)
09-26 16:24:03.457: E/AndroidRuntime(11692): at com.example.project2.sipwork.run(sipwork.java:193)
第 153 行:
sipman.setRegistrationListener(sipprofile.getUriString(), new SipRegistrationListener() {
第 193 行:
setlisten();
private SipProfile buildsip(JSONObject sipcreds ) throws JSONException, ParseException{
SIP_USER = sipcreds.getString("username");
SIP_PASSWORD = sipcreds.getString("password");
if (sipman == null){
sipman = SipManager.newInstance(context);
}
SipProfile.Builder builder = new SipProfile.Builder(SIP_USER, SIP_DOMAIN);
builder.setPassword(SIP_PASSWORD);
builder.setAuthUserName(sipcreds.getString("username"));
builder.setAutoRegistration(true);
builder.setOutboundProxy(SIP_DOMAIN);
SipProfile mSipProfile = builder.build();
if (mSipProfile == null) {
Log.d("problem", "that seems to be the problem");
}
return mSipProfile;
}
private void sipint(SipProfile sipprofile) throws SipException{
Intent intent = new Intent();
intent.setAction("android.example.project2.INCOMING_CALL");
PendingIntent pendingIntent = PendingIntent.getBroadcast(context, 0, intent, Intent.FILL_IN_DATA);
sipman.open(sipprofile, pendingIntent,null);
if (sipman == null){
Log.d("problem", "found the null");
}
SipProfile sipprofile = buildsip(sipcreds);
sipint(sipprofile);
setlisten();