Dialing Phone Button Question.

Joel Fonseca

Member
Licensed User
Longtime User
Hi everyone,

in my application i have a button that does this:

B4X:
Sub Button1_Click
      Mediaplayer1.Initialize
      MediaPlayer1.Load(File.DirAssets, "Click1.wav")
      MediaPlayer1.Play
    

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

If I press that button the phone starts immediately calling that number, well that's is OK for me, because I want that button to make the phone call, but when I install the program to my htc desire hd phone, it displays a warning msg saying that this program can call ppl and make expensive phone calls directly...

What can I do so this warning don't get displayed and what is the code that I can use to display some kind of option once the user press that button, it displays the option if he wants to call that number or not, if he press yes he calls the number, if press no, it goes back to the previous activity.

Is this possible?, I hope I make myself clear.

Thanks in advance,

Joel Fonseca
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
In order to make a phone call your application declares the PHONE_CALL permission. You can see it here: Basic4android - Phone
Android will not allow you to make a phone call without declaring this permission.

You can show a Msgbox and check the result:
B4X:
    If Msgbox2("Do you want to make this call?", "", "Yes", "", "No", Null) = DialogResponse.POSITIVE Then
        'make call
    End If
 
Upvote 0

Joel Fonseca

Member
Licensed User
Longtime User
B4X:
Sub Button1_Click
      Mediaplayer1.Initialize
      MediaPlayer1.Load(File.DirAssets, "Click1.wav")
      MediaPlayer1.Play
    

      Dim p As PhoneCalls      
      
      If Msgbox2("Deseja ligar ?", "", "Sim", "", "Não", Null) = DialogResponse.POSITIVE Then
        'make call
      
      StartActivity(p.Call("123456789"))
      
    End If
      
End Sub

Many thanks, it worked like a charm

:sign0098:
 
Upvote 0

robife

Member
Licensed User
Longtime User


Thanks a lot
This thread help me too :sign0098:
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…