Hi,
I have a problem that my project need to auto answer call for special reason. AnswerCall Lib does not work. I try this code. But, It does not work too. Would you help me ? Thanks !
I have a problem that my project need to auto answer call for special reason. AnswerCall Lib does not work. I try this code. But, It does not work too. Would you help me ? Thanks !
B4X:
Sub GetContext As JavaObject
Return GetBA.GetField("context")
End Sub
Sub GetBA As JavaObject
Dim jo As JavaObject
Dim cls As String = Me
cls = cls.SubString("class ".Length)
jo.InitializeStatic(cls)
Return jo.GetFieldJO("processBA")
End Sub
Sub answerCall
Log("Answer Call !!!!")
Dim ke As JavaObject
Dim i1 As Intent
Try
i1.Initialize("android.intent.action.MEDIA_BUTTON","")
ke.InitializeNewInstance("android.view.KeyEvent", Array As Object(1, KeyCodes.KEYCODE_HEADSETHOOK ))
i1.PutExtra("android.intent.extra.KEY_EVENT", ke)
GetContext.RunMethod("sendOrderedBroadcast", Array As Object(i1,"android.permission.CALL_PRIVILEGED"))
Catch
ToastMessageShow(LastException.Message,True)
Log("answer_call() " & LastException.Message)
End Try
End Sub