Question

On Android studio, how to call a phone number from a button? Like when the user...

On Android studio, how to call a phone number from a button? Like when the user click on a buttom on the aplication, it direct him to a phone call

thanks

0 0
Add a comment Improve this question Transcribed image text
Answer #1

@Override

protected void onCreate(Bundle savedInstanceState){

super.onCreate(savedInstanceState);

setContentView(R.layout.activity_main);

findViewById(R.id.button).setOnClickListener(new View.onClickListener(){

@Override

public void onClick(View v){

dialContactPhone("Any phone number to be inserted here");

}

});

}

private void dialContactPhone(final String pno){

startActivity(new Intent(Intent.ACTION_DIAL, Uri.fromParts("tel", phoneNumber, null)));

}

This code will allow you to call the number specified in the code to be called once the required button is pressed.

Add a comment
Know the answer?
Add Answer to:
On Android studio, how to call a phone number from a button? Like when the user...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • In android studio, I want to get the user current location when he clicks on a...

    In android studio, I want to get the user current location when he clicks on a button after asking him for the permission, store its latitude and longitude on double variables and then do calculations depends on the user location, How can I do that in maps activity? I want on click to be outside onCreate, I want inside on click to get double lat = latlong.getlatutide not to call function getlocation

  • (Android Studio) Create a camera app that allows the user to upload a picture from their...

    (Android Studio) Create a camera app that allows the user to upload a picture from their phone camera gallery, see the picture via summary page, and edit the picture as well. Clicking on "Insert picture here from camera photo gallery" in the add page will allow the user to upload a picture from their existing camera photo gallery on their phone. The user can choose where to save the picture, starting with Picture 1-5. Once they choose where to save...

  • Android Studio (Java) Develop an android app that contains two fragments displayed on one activity. The...

    Android Studio (Java) Develop an android app that contains two fragments displayed on one activity. The bottom fragment contains / displays several rows of individual buttons and each of these buttons resemble a letter of the alphabet such as the first button "A" second button "B" etc.. all the way to Z as well as buttons for the numbers 0 - 9. Once a user clicks a button, the corresponding letter or number button they pressed should display in the...

  • Hi ?, I have a question in the android studio, I am using button sheet to...

    Hi ?, I have a question in the android studio, I am using button sheet to display information, I want to display the button sheet depending on condition, display or hidden and, when collapse and expand the bottom sheet is repeated on background how to solve this problem?

  • Using Android Studio Java, create a program which has two functions: Function1: has a text field...

    Using Android Studio Java, create a program which has two functions: Function1: has a text field and a button to invoke "Function 2" Function 2: process the data entered in the text field on Function 1. If data in text field starts with "url:" (for e.g. url:www.google.com or url:www,palomar.edu), display the URL in the default browser. If data in text field starts with "phone:" ( for e.g. "phone:7607441150"), call the phone number using the dialer application.

  • 9. Android programming uses a different paradigm for GUI programming interaction, like when the user presses...

    9. Android programming uses a different paradigm for GUI programming interaction, like when the user presses a button. Please describe this paradigm and how it works: 10. Before running an app in the emulator you must create what? Please list everything that can be defined?

  • I need help developing this app using java in android studio Assignment: Tic-Tac-Toe app User interface...

    I need help developing this app using java in android studio Assignment: Tic-Tac-Toe app User interface Operation The app allows the user to play a game of Tic-Tac-Toe. The user can click the New Game button at any time to start a new game. The app displays other messages to the user as the game progresses such as (1) whose turn it is, (2) if a player wins, and (3) if the game ends in a tie. Specifications The app...

  • (Mobile-Android Studio) Hello. Thank you for coming to help me:) I am using the Andriod studio...

    (Mobile-Android Studio) Hello. Thank you for coming to help me:) I am using the Andriod studio on mac. and using Java code to develop. and Please start with basic activity with constraints layout (not empty). (audio file is not given, let's say there any audio file). I just would like to see the codes how it works. Thank you very much. I would like to know how to write a program that includes two buttons called plays Play and Stop....

  • 1. Write an Android phone program such that one instance of EditText, one instances of Button,...

    1. Write an Android phone program such that one instance of EditText, one instances of Button, one instance of TextView, and another instance of EditText are displayed vertically on the AVD. The users of your program will be asked to input a positive integer, denoted n, in the first instance of EditText. When the users click the button instance, the binary representa- tion of n will be displayed in the instance of TextView and a specified trian- gular pattern consisting...

  • Project 03 (Chapter 04 Multiple Activities) Code an app in android studio that does the following:...

    Project 03 (Chapter 04 Multiple Activities) Code an app in android studio that does the following: There is one button in the middle of the screen. The button color is green and its text says 0. When the user clicks on the button GO, we go to a second activity that is red and has one button in the middle of the screen; its text says BACK. When the user clicks on that button, we go back to the first...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT