Android Question how do I make a button call?

ander47

Member
hi! please help me whith library PHONE...
I write the call code by number when I press the button. But my code doesn't work. I get errors in the debugger

my code is:



Sub Class_Globals
Private Root As B4XView
Private xui As XUI


End Sub

Public Sub Initialize

End Sub

Sub Activity_Create(FirstTime As Boolean)

If FirstTime Then
End If
End Sub


Private Sub Button1_Click


Dim p As PhoneCalls
StartActivity(p.Call("123456789"))

End Sub


error debugger in files...
 

Attachments

  • error.jpg
    221.1 KB · Views: 103

JohnC

Expert
Licensed User
Longtime User
You can try this:
B4X:
Dim I As Intent
I.Initialize(I.ACTION_CALL, "tel:" & phonenumber)
StartActivity(I)

And make sure you have this in your manifest:
B4X:
AddPermission(android.permission.CALL_PHONE)

And have this for the runtime permission:
B4X:
Dim RP As RuntimePermissions
RP.CheckAndRequest(RP.PERMISSION_CALL_PHONE)
Wait For Activity_PermissionResult (Permission As String, AskResult As Boolean)
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
Upvote 0

ander47

Member
Private Sub Button1_Click




Dim p As PhoneCalls
StartActivity(p.Call("89259644311"))

Dim CurrentCall As SipAudioCall


If CurrentCall.IsInCall == 1 Then
CurrentCall.SendDtmf(2)



End If


End Sub


but this code is no work(
 
Upvote 0

toby

Well-Known Member
Licensed User
Longtime User
No permission nor change to manifest is needed to make phone call via intent
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…