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
  • (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...

  • 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.

  • 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...

  • Write an Android App that calculates the days remaining from the current date until the user...

    Write an Android App that calculates the days remaining from the current date until the user selected date. Display a fragment which has a single button labeled “Select Date”.   When that button is pushed a Dialog should be displayed with a DatePicker widget inside. After the user selects the date, calculate the difference in days and display it back on the original fragment.

  • In Android Studio, how can I make a shape change color based on information read from...

    In Android Studio, how can I make a shape change color based on information read from a database? (Java and xml code would be most helpful)

  • If anyone here is a Java and Android Studio expert please I really need help fulfilling...

    If anyone here is a Java and Android Studio expert please I really need help fulfilling the requirements needed to make a Rock Paper Scissors game. I mainly need Java code to complete it I will post what I have so far I don't have much time left please if anyone can help me I would really appreciate it. Here's what the app is supposed to do... The player should be able to select either Rock, Paper, or Scissors.The app...

  • Please help me with this project by using Android Studio. I need to know the xml...

    Please help me with this project by using Android Studio. I need to know the xml and the java activities in both activities. Also the manifest activity. I appreciate the effort and I'll rate you with 5 stars. 1. SUMMARY This project will simulate the card game Concentration for one player. In Concentration, all cards, or pictures in this case, are upside down. Two cards are chosen, and if they match they are taken out of the game. If they...

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
ADVERTISEMENT