在擴展了線程的類內sipmanger.open後調用以下內容。我檢查了是否有任何參數爲空,但它們不是。調用SetRegistrationListener時發生空指針異常
任何想法?
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();
如果你正在得到一個NPE,你能發佈logcat嗎?因爲* *是* null。 – codeMagic
您可以添加NullPointerException的堆棧跟蹤嗎? – icyitscold
什麼是第153行? – codeMagic