Android Question code to grasp incoming number and send sms

Hello there guys, this a part of an app i'm working on; i really need a code to grasp and incoming number and send it a sms automatically, if that cant be done then i need a code that will automatically send sms as immediately the call went off.
i would also loved it , if this code can be rewired ; for i need the code to run in background
'Service module


'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 callStartTime, callEndTime As Long
Dim isIncoming As Boolean
Dim lastState As String = "IDLE"
Dim savedNumber As String
End Sub

Sub Service_Create
lastState = "IDLE"
PE.InitializeWithPhoneState("PE",PhId)
End Sub

Sub PE_PhoneStateChanged (State As String, IncomingNumber As String, Intent As Intent)
'Incoming call- goes from IDLE To RINGING when it rings, To OFFHOOK when it's answered, to IDLE when its hung up
'Outgoing call- goes from IDLE To OFFHOOK when it dials out, To IDLE when hung up

If State = lastState Then
Return
End If
Select State
Case "RINGING"
'calling in progress
isIncoming = True
callStartTime = DateTime.Now
savedNumber = IncomingNumber

Exit
Case "OFFHOOK"
'Transition of ringing->offhook are pickups of incoming calls. Nothing donw on them
If lastState <> "RINGING" Then
'outgoing call start
isIncoming = False
callStartTime = DateTime.Now

End If
Exit
Case "IDLE"
'Went to idle- this is the end of a call. What type depends on previous state(s)
If lastState = "RINGING" Then
'missed call
callEndTime = 0
else if isIncoming Then
'incoming call is finished
callEndTime = DateTime.Now
Else
'outgoing call is finished
callEndTime = DateTime.Now
End If

Exit
End Select
lastState = State

'Log("PhoneStateChanged, State = " & State & ", IncomingNumber = " & IncomingNumber & "; PhoneFlag = " & PhoneFlag)
End Sub
 

kisoft

Well-Known Member
Licensed User
Hello, some useful information for you :
 
Upvote 0
Top