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

How to detect incoming call

Discussion in 'Android Development' started by uaeHamed, May 25, 2011.

  1. uaeHamed

    uaeHamed Newbie
    Thread Starter

    Hi. Im working on an application that does something during a call. So I understand I need to use a service. But how does my application detect that a call is incoming or the call is answered or whatever before I launch the service?
     



    1. Download the Forums for Android™ app!


      Download

       
  2. miXer

    miXer Android Enthusiast

    To listen for change in calls you can use a broadcast with action: android.intent.action.PHONE_STATE:
    Code (Text):
    1. <receiver android:name=".CallReceiver">
    2.             <intent-filter>
    3.                 <action android:name="android.intent.action.PHONE_STATE" />
    4.             </intent-filter>
    5.         </receiver>
    And you can check the EXTRA_STATE in the intent given with the broadcast:
    Code (Text):
    1. String callState = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
     
    uaeHamed likes this.
  3. uaeHamed

    uaeHamed Newbie
    Thread Starter

    So my class will be a BroadcastReceiver class and on receive() it will implement my action?
     
  4. BitGriff

    BitGriff Lurker

    I wrote an article with detailed instructions, how to make it.

    I used broadcast receiver for outgoing calls, and PhoneStateListener for incoming. Calls detection code running in service.

    Article include detailed source code. You can modify it for your own needs.

    You can see it here:
    BitGriff: Detecting incoming and outgoing phone calls on Android.
     
Loading...
Similar Threads - detect incoming call
  1. Yamil_alv
    Replies:
    1
    Views:
    1,050
  2. Bhavin Lathia
    Replies:
    4
    Views:
    742
  3. Rasil1127
    Replies:
    2
    Views:
    682
  4. App Update
    Replies:
    1
    Views:
    562
  5. kiranmatrixlee
    Replies:
    0
    Views:
    988
  6. DR1964
    Replies:
    9
    Views:
    1,037
  7. Daniel Pedersen
    Replies:
    3
    Views:
    1,444
  8. TsubasaChronix
    Replies:
    0
    Views:
    1,810
  9. HuaweiY7Pro2019_Tyong
    Replies:
    4
    Views:
    1,182
  10. gingersnap
    Replies:
    7
    Views:
    1,094

Share This Page

Loading...