Help With PhoneEvents

SoyEli

Active Member
Licensed User
Longtime User
Hello :)

I got the "ToastMessageShow(strNumber, True)" to work but
not the textbox's
When phone rings the app terminates and I get a regular screen with the ToastMessageShow showing the number, after hangup
reloads debugger and app.

What am i missing?

Thank you :confused:

Sub PE_PhoneStateChanged (State As String, IncomingNumber As String, Intent1 As Intent)
strNumber = IncomingNumber
strState = State
'State - One of the three values: IDLE, OFFHOOK, RINGING. OFFHOOK means that there is a call or that the phone is dialing.

ToastMessageShow(strNumber, True)
'Then something like:
If strState = "RINGING" Then
EditText1.Text = strNumber
End If
If strState = "IDLE" Then
EditText1.Text = "IDLE"
End If
If strState = "OFFHOOK" Then
EditText1.Text = "OFFHOOK"
End If
End Sub
 

fransvlaarhoven

Active Member
Licensed User
Longtime User
Hello,

i'm currently working on an extension of the Kiosk-example of Erel.

The problem is that i want to block all incomming calls.
I can detect an incomming call using PhoneEvents_PhoneStateChanged, no problem here.
I can force the phone in silent mode using myPhone.SetRingerMode(myPhone.RINGER_SILENT), again no problem..

But it would be nice if it was also possible to do the following things:

1. when an incomming call is detected: terminate the incomming call.
2. when PhoneStateChanged from State= IDLE to State= OFFHOOK: force back to IDLE

it looks as the package "com.android.phone" can do this but I've no idea about the intents to broadcast etc.

Any suggestions?

Thanks,
 
Upvote 0

fransvlaarhoven

Active Member
Licensed User
Longtime User

answercall-library is not giving the right answer.

However, something that i found on another thread in this forum does:

private Sub PhoneEvents_PhoneStateChanged (State As String, IncomingNumber As String, Intent As Intent)
'stop phone from ringing and kill the incomming call
If State= "RINGING" Then
Dim r As Reflector
r.Target = r.GetContext
Dim TelephonyManager, TelephonyInterface As Object
TelephonyManager = r.RunMethod2("getSystemService", "phone", "java.lang.String")
r.Target = TelephonyManager
TelephonyInterface = r.RunMethod("getITelephony")
r.Target = TelephonyInterface
r.RunMethod("endCall")
StartActivity(Main)
ToastMessageShow("blocking incomming call from " & CRLF & IncomingNumber, True)​
End If​
End Sub​
many thanks for a tool as nice as B4A.....:)
 
Upvote 0
Top