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