Android Question Get outgoing Call number??

ilan

Expert
Licensed User
Longtime User
hi

i am using this code to get the outgoing call number (via a service)

B4X:
 If startingIntent.Action = "android.intent.action.NEW_OUTGOING_CALL" Then
      If startingIntent.HasExtra("android.intent.extra.PHONE_NUMBER") Then
         Dim myphone As String
         myphone = startingIntent.GetExtra("android.intent.extra.PHONE_NUMBER")
    
         Log(myphone)       
       
      End If
   End If

the problem is that this code needs the android.permission.PROCESS_OUTGOING_CALLS permission.

i saw a lot call recording apps that does not need that permission, is there another way to get the outgoing call Number without using the (not very much sympathetic) PROCESS_OUTGOING_CALLS permission?

thanx
 

ilan

Expert
Licensed User
Longtime User
I think they use this to call:
B4X:
   Intent intent = new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" + phone_number));
   startActivity(intent);

Source: Stackoverflow

Thanx but i dont want to perform a call i just want to tigger the phone number on an outgoing call via service.

So when the phone is calling via the default android dialer i want with a service to get the calling number.

The code in the first post is working it is only requiring a permission i dont want to have in my app (allow phone to make outgoing calls)

But i am not using my app to dial its a call recorder and when an outgoing call is performed i want to store that record with the dialed number.
 
Upvote 0

a n g l o

Active Member
Licensed User
Longtime User
i came across this post that is almost a year old and i see that the the questioner did not get exactly the answer he was looking for :
1. get the outgoing call number (via a service)
2. not having to use android.permission.PROCESS_OUTGOING_CALLS

i don't believe he's still waiting for the answer... but in case someone else running same search ( as i did ) - i've made it like that :
B4X:
Sub getDialedNumber As String
                Dim callsLog As CallLog
                Dim call As CallItem
                Dim list1 As List
                Dim dialedNumber As String
       
                list1=callsLog.GetAll(1)
                call=list1.Get(0)
               
                If call.CallType=call.TYPE_OUTGOING Then
                            dialedNumber=call.CachedName & " - " & call.Number
                End If
                Return dialedNumber
End Sub

Thank you
 
Upvote 0
Top