Get the number of the current caller

Koushik

Member
Licensed User
Longtime User
Hi,

Is it possible to get the number of caller currently on call? My requirement is to get the number of the caller programmatically when the application is open.

Any help would be highly appreciated.

Thanks
Koushik
 

peacemaker

Expert
Licensed User
Longtime User
Hi,

Is it possible to get the number of caller currently on call?

Thanks
Koushik


B4X:
'Service module
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.
   Dim PE As PhoneEvents
   Dim PhId As PhoneId
   Dim PhoneFlag As Int
   
   Dim Notif1 As Notification
   
End Sub

Sub Service_Create
PE.InitializeWithPhoneState("PE",PhId)

   Notif1.Initialize
   Notif1.Icon = "icon" 'use the application icon file for the notification
   Notif1.Vibrate = False
   PhoneFlag = 0
End Sub


Sub PE_PhoneStateChanged (State As String, IncomingNumber As String, Intent As Intent)
   main.PhoneState = State
   If State = "RINGING" AND IncomingNumber<>"" Then 'incoming call
      main.LastInNumber = IncomingNumber
      PhoneFlag = 1
      ToastMessageShow("Caller: " & IncomingNumber, True)
   End If
   If State = "OFFHOOK" AND IncomingNumber="" AND PhoneFlag = 1 Then 'answering to incoming call
      PhoneFlag = 2
   End If
   If State = "OFFHOOK" AND IncomingNumber="" AND PhoneFlag = 0 Then   'out call
      main.LastInNumber = IncomingNumber
      PhoneFlag = 4
   End If
   If State = "IDLE" AND main.LastInNumber <> "" AND PhoneFlag = 2 Then 'just input call finished
      PhoneFlag = 3
      If main.LastInNumberContact = Null Then 
         StartActivity("Main")
      End If
   End If
   If State = "IDLE" AND main.LastInNumber <> "" AND PhoneFlag = 1 Then 'just rejected input call
      PhoneFlag = 0
   End If
End Sub

Sub Service_Start

Notif1.SetInfo("ApplicationTitle", "Working in background...", Main)
Notif1.Sound = False
Notif1.Notify(1)
Service.StartForeground(1, Notif1) 

End Sub


Sub Service_Destroy
Service.StopForeground(1)
End Sub

Note Phone lib reference.
 
Upvote 0

Koushik

Member
Licensed User
Longtime User
Hi peacemaker,

Thanks a lot for the information and the code, and apologies for late reply.

However, what is the type of "main" here in the code? as I am getting error for all the properties of mail e.g. main.LastInNumber


Thaks again for your help.
Koushik
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
This is an old thread. Create a New one instead asking here
 
Upvote 0
Top