how to create an Android app that you have to press on the app icon and it calls a single number

Asked

Viewed 58 times

-1

I’m starting in mobile development and would like to create an app, in which you can register a number and whenever you click on the icon of the program he would make a call to that same number

  • Hello, welcome to SOPT. This site is not a forum. It is clear what you want/need to do, but it is unclear what your specific doubt or difficulty is. If you haven’t done it yet, do the [tour] and read [Ask]. You already have an answer that explains how to make a call to a number. So if you change your question to be specific about that, I withdraw my vote to close. :)

1 answer

3

First you create the button:

((Button)findViewById(R.id.button1)).setOnClickListener(new OnClickListener() {
 @Override
  public void onClick(View v) {
  String phno="10digits";

  Intent i=new Intent(Intent.ACTION_DIAL,Uri.parse(phno));
  startActivity(i);
}
});

I made that example but it doesn’t necessarily mean that.

Next, we have to give permission to manifest file:

<uses-permission android:name="android.permission.CALL_PHONE"></uses-permission> 

And inside the Activity:

Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:123456789"));
startActivity(callIntent);

Although you haven’t expressed it the way plus correct your problem, a while ago I had this same problem, researched it and solved it in the way I indicated.
Whichever doubt dispose.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.