outcomingNumber in PhoneStateChanged

CapReed

Member
Licensed User
Longtime User
Good morning,

I am making an application that intercepts incoming calls. PE_PhoneStateChanged I use to capture the events, without any problem.

PE_PhoneStateChanged (State As String, IncomingNumber As String, Intent As Intent)

With PE_PhoneStateChanged also find out if there is any outgoing call working correctly, but, how I can know which is the number I am calling, that is, the outcomingNumber?

Thank you!
 

CapReed

Member
Licensed User
Longtime User
Ok, thank you Erel!

This the response from @bsnqt and it's good for my. ;-)

You should be familiar with the sms interception sample project first, as indicated by Erel. Then you can try with the interception of an outgoing phone call. I can confirm that Erel advised you the best way to get it work.

You will need to create a service to listen to the new outgoing call and put this working code into your service module.


B4X:
Sub Service_Start(startingIntent AsIntent)
If startingIntent.Action = "android.intent.action.NEW_OUTGOING_CALL"ThenIf startingIntent.HasExtra("android.intent.extra.PHONE_NUMBER") ThenDim myphone AsString
myphone = startingIntent.GetExtra("android.intent.extra.PHONE_NUMBER")
Log(myphone)
EndIfEndIf
End Sub

It works for me 100%. See the outgoing call number in the log window.

But before debugging you will need also to add into the manifest editor the following:



B4X:
AddPermission(android.permission.PROCESS_OUTGOING_CALLS)
AddReceiverText(intentsms, <intent-filter>
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>)
Don't forget to change the name "intentsms" - which is the name of the service in my project - by the name of the service in your project.
 
Upvote 0
Top