Hello everyone, I would like to create an app that allows me to make a sequence of phone calls to be interrupted while it is ringing after about 5 seconds, every 5 seconds the app must call a number entered in a list of numbers and when it closes the call switch to next number, the problem lies in blocking the call in progress, being that during the call the app goes in the background there is a method to intercept the end call button from the code or to be able to close the call automatically? I am using the phone library to make the call but I don't find how to close it automatically after a few seconds.
B4X:
#Region Project Attributes
#ApplicationLabel: Auto_Chiamate
#VersionCode: 1
#VersionName: 1.0
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: portrait
#CanInstallToExternalStorage: True
#BridgeLogger: True
#End Region
#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
Private btnchiama As Button
Private rp As RuntimePermissions
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Layout")
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub btnchiama_Click
rp.CheckAndRequest(rp.PERMISSION_CALL_PHONE)
Wait For Activity_PermissionResult ( Permission As String, Result As Boolean)
If Result Then
Dim p As PhoneCalls
StartActivity(p.Call("xxxxxxxx"))
Else
I see a lot of questions that it's impossible to end call programmatically in Android. At the same time, I see a lot of dialer apps in googleplay market where you can activate the call and drop it ...
Sub KillCall
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")
End Sub
Sub KillCall
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")
End Sub
starter_v5 (java line: 161)
java.lang.NoSuchMethodException: java.lang.Object.endCall []
at java.lang.Class.getMethod(Class.java:2072)
at java.lang.Class.getDeclaredMethod(Class.java:2050)
at anywheresoftware.b4a.agraham.reflection.Reflection.runmethod(Reflection.java:214)
at anywheresoftware.b4a.agraham.reflection.Reflection.RunMethod(Reflection.java:802)
at b4a.example.starter._v5(starter.java:161)
at b4a.example.starter._timerkill_tick(starter.java:205)
at java.lang.reflect.Method.invoke(Native Method)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:213)
at anywheresoftware.b4a.objects.Timer$TickTack.run(Timer.java:105)
at android.os.Handler.handleCallback(Handler.java:883)
at android.os.Handler.dispatchMessage(Handler.java:100)
at android.os.Looper.loop(Looper.java:237)
at android.app.ActivityThread.main(ActivityThread.java:7948)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1075)
Sub KillCall
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")
End Sub
Please note:
At the same time the original endCall() method under TelephonyManager is now protected by MODIFY_PHONE_STATE permission, and can no longer be invoked by non-system Apps by reflection without the permission (otherwise a Security Exception will be triggered).
i am using b4a 7.03 Galaxy J7 Max platforms\android-23\android.jar 'comes inside this sub sub PE_PhoneStateChanged (State As String, IncomingNumber As String, Intent As Intent) AC.AnswerPhone ' this is not fired at all can anyone help please