how to create an Android app that you have to press on the application icon and it connects to a single [closed]

-1

I'm starting in mobile development and would like to create an app where I could register a number and whenever I clicked on the program icon it would call the same number

    
asked by anonymous 03.06.2016 / 12:41

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 this example but it does not necessarily mean that way.

Next, we have to give permission to manifest file:

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

And within activity:

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

Although you did not express your problem the more correct problem, some time ago I had this same problem, I researched it and solved it the way I indicated.
Any doubts you have.

    
03.06.2016 / 13:00