aris

Lurker
Dec 23, 2013
3
0
5
Hi everybody. i'm new to android dev and i'm using sip library to create a sip application to make/receive sip calls. The library gives a 'phone' instance which I can call the methods to do the job. To get the instance of the phone, i use this line:

[HIGH]
Phone instance = ((phoneApplication) getApplication()).getInstancePhone();
[/HIGH]

the library it works great and do what i want. My Problem is that when using it from activity, when activity dies by the system the instance does not exist any more and the app crash when receives a call from sip server. How can i keep my instance alive?
Any help will be greatly, greatly appreciated!
Thanx
 
Are you using a BroadcastReceiver to intercept the incoming call from the server and then send out an intent to an activity that manages the call?

Another option could be to keep it running as a service rather than an activity to receive a call as one the activity is killed, the instance would not be available as you said. Instead of that you could have it running as a service so that it is ready to receive the incoming call from the server.
 
Hi RamandeepBakshi, thanx for your reply.
The library gives some listeners to use with instance "phone" to listen for sip server events. Something like that:
instancephone.OnIncomingCallListener

when listener triggers i'm sending intent to an activity to manage the call.
Now if use a persistent service that is always running, it will drain the resources of the phone and i want to avoid that. How can keep an instance of the phone listening away for incoming calls without draining the resources of the phone?
Cheers,
Aris
 
I use abtophone sip sdk for android. I know that can use a service, but my thought is if can have an instance of global application seperately from activity so it won't kill when app goes to the background.

thanx again