1. Are you ready for the Galaxy S20? Here is everything we know so far!

Activity and application instance

Discussion in 'Android Development' started by aris, Dec 23, 2013.

  1. aris

    aris Lurker
    Thread Starter

    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!

    1. Download the Forums for Android™ app!


  2. 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.
  3. aris

    aris Lurker
    Thread Starter

    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?
  4. Which library are you using by the way? This doesn't seem to be in the default Android SIP API.

    This question should have been in my previous post though. But I cannot help you much unless I know what you are working with.
  5. aris

    aris Lurker
    Thread Starter

    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

Share This Page