Android Tutorial Android Sip / Voip tutorial

luke2012

Well-Known Member
Licensed User
Longtime User

This is my first approach to Service Module.
In a service perspective I have to initialize the SIP object (the same code of the Activity_Create) within the Service_Create, correct?

The service must include also the "SIP_CallRinging" event in order to instantiate the "CurrentCall" object correct?
 

luke2012

Well-Known Member
Licensed User
Longtime User
Erel as you suggested I'm implementing a service that handle SIP calls.

The service start at system boot and initialize the SIP & CurrentCall objects.

It's work fine also when the app isn't in foreground but when a user close the app (for example with Android task manager) also the Process Global objects are killed (SIP & CurrentCall) and the SIP service became unavailable for the Caller.

Implementing a specific app that handle SIP service and a specific app that handle user interface could solve the problem?
Any other solution ?
 

luke2012

Well-Known Member
Licensed User
Longtime User
I read the "long running background tasks" and I'm thinking to implement the 2° solution "Service.StartForeground".

1) In this scenario I have to change the automatic "start at boot" (B4A) to "Service.StartForeground".
2) I have to execute the app at system boot in order to call Service.StartForeground method (I need that the service will be always available at system boot).

Is this correct?
 
Last edited:

luke2012

Well-Known Member
Licensed User
Longtime User
If the user has installed a custom task manager then he can kill the process no matter what...

Service.StartForeground is not really related to "start at boot". Just call Service.StartForeground in Service_Create.

Assuming that the user cannot install custom task manager, I can set the service as "Start at boot" and call Service.StartForeground in Service_Create in order to have a always available service?
 

luke2012

Well-Known Member
Licensed User
Longtime User
I implemented a service that handle sip calls.
My tests :

1) Calling from SIP sample app to my app (sip as service) = OK
2) Calling from my app to my app = no audio (all events are raised as expected)

The difference points are:

1) The SIP and SipAudioCall objects are created in the Service module
2) The SIP_CallRinging and SIP_CallEstablished has been implemented within the Service module (the code are the same of the sample app)
 
Last edited:

luke2012

Well-Known Member
Licensed User
Longtime User
I'm using the code of the example to initialize SIP within the Service.
The SIP_Calling event is raised so the SIP is initialized.

If you want I can send you the project (I prefer via eMail).
 
Last edited:

luke2012

Well-Known Member
Licensed User
Longtime User
Your code looks correct. The problem is that CurrentCall.StartAudio doesn't have any effect when its done in the service, right?

Yes!
If the caller is a CurrentCall object within the main activity in the foregroud app (your example attached in this tutorial) and the "receiver" is a CurrentCall object within the service (my code) I can hear the audio.

The problem is between my service and my service (in this case the CurrentCall object in both case is within the service).
 

luke2012

Well-Known Member
Licensed User
Longtime User
Not sure why it happens. You can try to show an activity during the call.

I known that the service interact only with logs & Notify messagges.
Could be that it can't interact directly with the audio of the phone ?
 
Cookies are required to use this site. You must accept them to continue using the site. Learn more…