Android Question Outgoing call... use PhoneStateChanged?

persianpowerman1

Active Member
Licensed User
Longtime User
hi guys...
i was studying PhoneStateChanged...
but not sure if it suits what i want... can some one advise me

Im basically trying to know... states about an OUTGOING CALL... thats when i am calling another phone..
How to get those states... like...
RINGING(after we've dialed their number)...
ANSWERED(by the other party)...
ON GOING CALL...

Thanx,
YO!han
 

bsnqt

Active Member
Licensed User
Longtime User
@persianpowerman1: I can successfully catch the OUTGOING CALL EVENT by using Broadcastreceiver library. Not sure that it does work for all versions Android or all phone models.
B4X:
Sub BroadcastReceiver_OnReceive (Action As String, BroadcastIntent As Object)

If myintent.Action = "android.intent.action.NEW_OUTGOING_CALL" Then
  
        If myintent.HasExtra("android.intent.extra.PHONE_NUMBER") Then
            Dim callnumber As String = myintent.GetExtra("android.intent.extra.PHONE_NUMBER")
          Log(callnumber)

        End If
      
    End If

End Sub

You should add this to manifest:

B4X:
' FOR OUTGOING CALLS
AddPermission(android.permission.PROCESS_OUTGOING_CALLS)
AddReceiverText(YourService, <intent-filter>
            <action android:name="android.intent.action.NEW_OUTGOING_CALL" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>)

Don't forget also to add this to the Service_Create Sub

B4X:
Broadcast.addAction("android.intent.action.NEW_OUTGOING_CALL")

Hope this can help you.

Note. With PhoneStateChanged, Erel is right, you cannot catch OUTGOING.
 
Upvote 0

persianpowerman1

Active Member
Licensed User
Longtime User
hmmm ... ok cool.. thanx erel..

hey bsnqt... your code looks promising... will give it a try... am travelling right now... should be home by night will try it then...

I basically was trying make what some app does... ie...
Suppose i dial your phone number... its ringing... the moment you pick up... i get a little vibration in my hand(so i know you have picked up)... it helps because... i dont have to sit with the phone stuck to my ear to realise you have picked up... got it

thanx.. will write back... lemme know if you can think of any work around

YO!han
 
Upvote 0

persianpowerman1

Active Member
Licensed User
Longtime User
Hey @bsnqt ... doing RnD with your idea...

I got another idea...
how about... being able to see when the dialer starts the time(that is when the call is picked up at the other end)... usually the timer for the call starts from 0:00... 0:01... 0:02...etc... pls see the image...

if i can catch that... it should work right? i would know when the other party that i am calling has picked up the phone... what say?.. any ideas

i've drawn an arrow around what im trying to say...
YO!han
 

Attachments

  • forB4A.png
    forB4A.png
    57.8 KB · Views: 270
Upvote 0
Top