Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: android sipmanager throwing nullpointer

  1. #1
    Member
    Join Date
    Apr 2013
    Posts
    83
    Thanks
    7
    Thanked 3 Times in 3 Posts

    Default android sipmanager throwing nullpointer

    hi i am trying to make a sip call using android api the code is below. the setRegistration Listener method is throwing an nullpointer for my sipprofile but the profile prints fine so am at a bit of a loss as to why its throwing the error. am very new to android this is my first project so any help would be great thanks.

     
    public void MakeACall(String a){
    		try {
     
    			String ad="calling "+a;//a is peer address
    			res1.setText(ad);//res1 is textview
    			String b=sp("name","getonsip.com","pass").getUriString();//local profile
    			res1.setText(b);			
                            System.out.println(b);//prints the sip profile fine
    			SipProfile mSipProfile = sp("name","getonsip.com","pass");
    			SipManager mSipManager =SipManager.newInstance(MainActivity.this);			
    			mSipManager.setRegistrationListener(b,//nullpointer error is thrown here<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
    					new SipRegistrationListener() {
                    public void onRegistering(String localProfileUri) {
                        res1.setText("Registering with SIP Server...");
                    }
     
                    public void onRegistrationDone(String localProfileUri, long expiryTime) {
                    	res1.setText("Ready");
                    }
     
                    public void onRegistrationFailed(String localProfileUri, int errorCode,
                            String errorMessage) {
                    	res1.setText("Registration failed.  Please check settings.");
                    }
                });
     
    			SipAudioCall.Listener whatWasThat = new SipAudioCall.Listener() {	    		
    	    	@Override
    	    	public void onCallEstablished(SipAudioCall call) {
    	    	call.startAudio();
    	    	call.setSpeakerMode(true);
    	    	call.toggleMute();
    	    	res1.setText("calling");
    	    	}
    	    	@Override
    	    	public void onCallEnded(SipAudioCall call) {	    	    
    	    		res1.setText("ended");
    	    	}
    	    	};
     
     
    	        mSipManager.makeAudioCall(sp("name","getonsip.com","pass").getUriString(), 
    	        		sp("other","getonsip.com","pass").getUriString(), whatWasThat, 30);
     
    		} catch (java.text.ParseException e) {
    			System.out.println("error with profile string thing");
    			e.printStackTrace();
    		} catch (SipException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    		}
    	}//end makecall()


  2. #2
    Member
    Join Date
    Apr 2013
    Posts
    83
    Thanks
    7
    Thanked 3 Times in 3 Posts

    Default Re: android sipmanager throwing nullpointer

    hi i am pritty sure from studying logs it actually a problem with gnerating the profile so the error is in sp() here is the code incase anyone can help
    public SipProfile sp(String a1,String b1,String c1) throws ParseException {	//generates sip profile	username,domain,password
    	SipProfile Profile = null;
     
    	SipProfile.Builder  builder = new Builder(a1,b1);
     
    	builder.setOutboundProxy("proxy.sipthor.net");
    	//builder.setAuthUserName("getonsip_username");
    	builder.setPort(5060);
    	builder.setProtocol("UDP");
    	builder.setPassword(c1);
        Profile = builder.build();
    //    System.out.println(Profile.getDisplayName());
    //	System.out.println(Profile.getPassword());
    //	System.out.println(Profile.getPort());
    //	System.out.println(Profile.getProfileName());
    //	System.out.println(Profile.getProtocol());
    //	System.out.println(Profile.getSipDomain());
    //	System.out.println(Profile.getUserName());
     
     
    	return Profile;

    the reason i have come to that conclusion is the print outs are also generating nullpointers so obiously im missing something tought id post incase anyone knew what im doing wrong

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: android sipmanager throwing nullpointer

    the print outs are also generating nullpointers
    That would mean that the variable used in all the print outs has a null value: Profile
    Can the build() method return a null value?
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. nullpointer exception when adding Object to ArrayList
    By bartolio in forum What's Wrong With My Code?
    Replies: 14
    Last Post: January 20th, 2013, 12:17 PM
  2. NullPointer exception error
    By davx in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 18th, 2012, 01:08 PM
  3. NullPointer Exception problem
    By anshu in forum What's Wrong With My Code?
    Replies: 3
    Last Post: June 26th, 2012, 06:38 AM
  4. [SOLVED] Nullpointer exception when sending string
    By treshr in forum What's Wrong With My Code?
    Replies: 3
    Last Post: August 26th, 2011, 04:36 AM