Advertise here




Advertise here

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

How do I detect call

m_kaminsky@yahoo.comm_kaminsky@yahoo.com Posts: 242Registered Users
edited May 2010 in iPhone SDK Development
Could someone help me? is there a boolean equivalent for "now receiving phone call"?
Post edited by m_kaminsky@yahoo.com on

Replies

  • macoholicmacoholic Posts: 137Registered Users
    edited June 2009
    No no bool variable as such but check the UIApplicationDelegate

    You will get a method
    - (void)applicationWillResignActive:(UIApplication *)application
    

    which is invoked in case of interruptions! :)
  • m_kaminsky@yahoo.comm_kaminsky@yahoo.com Posts: 242Registered Users
    edited June 2009
    macoholic wrote: »
    No no bool variable as such but check the UIApplicationDelegate

    You will get a method
    - (void)applicationWillResignActive:(UIApplication *)application
    

    which is invoked in case of interruptions! :)


    interesting.. I'm wondering how I could use that because I want to
    have a general phone behavior of "if the phone rings, and ...then do that"
    like , as a background setting...impossible? Can that interuption method be accessed directly? like

    if applicationWillResignActive true (

    do stuff..

    )
  • BuckyBucky Posts: 356Registered Users
    edited June 2009
    If you implement the applicationWillResignActive: method in your app delegate, the system will trigger it for you when an interruption (such as a phone call happens). ie put everything you want to do when the phone rings in that method. Bear in mind that you won't get long, nor can you block the phone call. If the method takes too long to execute, the system will just terminate your app to let the phone call through.
  • m_kaminsky@yahoo.comm_kaminsky@yahoo.com Posts: 242Registered Users
    edited June 2009
    Bucky wrote: »
    If you implement the applicationWillResignActive: method in your app delegate, the system will trigger it for you when an interruption (such as a phone call happens). ie put everything you want to do when the phone rings in that method. Bear in mind that you won't get long, nor can you block the phone call. If the method takes too long to execute, the system will just terminate your app to let the phone call through.


    Is the applicationWillResignActive a background process or an app? ..If I wanted to invoke say an alert sound if a call is longer than 1 minute?
  • FlyingDiverFlyingDiver Posts: 997Registered Users
    edited June 2009
    Is the applicationWillResignActive a background process or an app? ..If I wanted to invoke say an alert sound if a call is longer than 1 minute?

    There are no background processes. Your app would have to be running as the current user application to get that notification.

    joe
  • BuckyBucky Posts: 356Registered Users
    edited June 2009
    Is the applicationWillResignActive a background process or an app? ..If I wanted to invoke say an alert sound if a call is longer than 1 minute?

    No, it's a delegate method. If you don't know what a delegate is, stop. Drop everything and learn about them. NOW!

    When a phone call comes through, this method is triggered. The user then has the opportunity to answer the call. If they choose not to answer it, your app continues as normal. If they choose to answer it, the system will quit your app. You also can't find any info about the incoming call before you ask. If this method takes too long, then the system will see this as an attempt to prevent the call, and will kill your app.
  • Duncan CDuncan C Posts: 9,022Tutorial Authors, Registered Users @ @ @ @ @ @ @
    edited March 2010
    Could someone help me? is there a boolean equivalent for "now receiving phone call"?

    I can tell by your questions that you haven't faced the hard reality of iPhone development yet: There are no background processes.

    If the phone rings, your app gets a terminate notice, and has a fraction of a second to clean up before it gets terminated. When the phone call ends, you will get launched again, so you get a chance to restore your app to the state it was in when the phone call arrived, but that is the extent of it.

    While a phone call is going on, you are as good as dead. The user can put the phone call into the background and launch your app again, but only Apple apps are able to run in the background.


    Regards,

    Duncan C
    Regards,
    Duncan C
    WareTo

    widehead.gif
    Animated GIF created with Face Dancer, available for free in the app store.

    I'm available for one-on-one help at CodeMentor
  • joby1joby1 Posts: 5New Users
    edited May 2010
    That is true if a call comes in.

    What about if a user makes a call, presses the home button then launches an app?

    This is very possible, so you can run an app during a call.

    Is there any way to detect if a call is currently going on? It would help for me on project.
Sign In or Register to comment.