Android Question Sip Register Problem don't invoke event

LuigiTasca

Member
Licensed User
Longtime User
Hi,
i'm having prolem when i try to call sip.register doesn't invoke any event and receive nothing. I think that i need to unregister the device that is already registered.
I found this code to unregister profile :
B4X:
Dim r As Reflector
                    r.Target = Sip
                    Dim manager As JavaObject = r.GetField("manager")
                    Dim profile As JavaObject = r.GetField("me")
                    manager.RunMethod("unregister", Array(profile, Null))

and implement after sip.registration but it goes in error
B4X:
java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4j.object.JavaObject.RunMethod(JavaObject.java:131)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:777)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:354)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at anywheresoftware.b4a.BA.raiseEvent(BA.java:193)
    at com.xxx.xxx.incomingcall.onCreate(incomingcall.java:56)
    at android.app.ActivityThread.handleCreateService(ActivityThread.java:3378)
    at android.app.ActivityThread.-wrap4(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1706)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:176)
    at android.app.ActivityThread.main(ActivityThread.java:6651)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:547)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:824)
Caused by: android.net.sip.SipException: SipService.createSession() returns null
    at android.net.sip.SipManager.unregister(SipManager.java:540)
    ... 19 more

Have you any ideas?
Where am I going wrong?

Regards.
 

LuigiTasca

Member
Licensed User
Longtime User
Ok,
This is on the Service_Create that manages calls.
B4X:
    Sip.Initialize("SIP", SipUtente,SipURI, SipPassword)
           
                   
    If SipPort > 0 Then
        Sip.Port = SipPort
        LogColor(SipPort,Colors.Blue)
    End If

    Sip.AutoRegistration = True
    Sip.Register

This are the event :
B4X:
Sub SIP_Registering
    Log("Registering")
   
End Sub

Sub SIP_RegistrationFailed (ErrorCode As Int, ErrorMessage As String)
    LogColor("Failed, ErrorCode=" & ErrorCode & ", Message=" & ErrorMessage,Colors.Red)
    ToastMessageShow("Registrazione fallita.", True)

End Sub

Sub SIP_RegistrationDone (ExpiryTime As Long)
    Log("RegistrationDone, ExpiryTime=" & ExpiryTime)
    ToastMessageShow("SIP registrato con successo", True)
   
End Sub

It was working until i've change device for the test and using the same username and password ...
The events were not invoked, then i've tryied to do that with another application (Zoiper) and it was working ...
I don't know why with another application works, but with my application doesn't do nothing

Regards
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…