• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Activity and application instance


Dec 23, 2013
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:

Phone instance = ((phoneApplication) getApplication()).getInstancePhone();

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!
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.
Upvote 0
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:

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?
Upvote 0


We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.