1. Download our Official Android App: Forums for Android!

Apps Activity and application instance

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

  1. aris

    aris Lurker
    Thread Starter
    Rank:
    None
    Points:
    5
    Posts:
    3
    Joined:
    Dec 23, 2013

    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
     

    Advertisement

  2. RamandeepBakshi

    Rank:
    None
    Points:
    25
    Posts:
    7
    Joined:
    Dec 24, 2013

    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
    Rank:
    None
    Points:
    5
    Posts:
    3
    Joined:
    Dec 23, 2013

    Dec 23, 2013
    3
    0
    5
    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?
    Cheers,
    Aris
     
  4. RamandeepBakshi

    Rank:
    None
    Points:
    25
    Posts:
    7
    Joined:
    Dec 24, 2013

    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
    Rank:
    None
    Points:
    5
    Posts:
    3
    Joined:
    Dec 23, 2013

    Dec 23, 2013
    3
    0
    5
    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

Loading...