调用SetRegistrationListener时出现空指针异常

时间:2013-09-26 23:18:43

标签: java android sip

在扩展线程类中的sipmanger.open之后调用以下内容。我检查了是否有任何参数为null而它们不是。

任何想法?

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();        

1 个答案:

答案 0 :(得分:0)

仔细检查变量sipmansipprofile是否不是null

相关问题