I created in my xml an EditText
and a Button
.
What I'm trying to do in the java is to let the user enter a number, then press the button and then i want the dialer to open with the input.
Is there a way to do it?
Thx.
I created in my xml an EditText
and a Button
.
What I'm trying to do in the java is to let the user enter a number, then press the button and then i want the dialer to open with the input.
Is there a way to do it?
Thx.
Yes there is!
You need to add a ClickListener
to your Button
and start the call intent:
dialButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
if (numTxt != null && (numTxt.getText().length()>0)) {// you can add other conditions if you want
startActivity(new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + numTxt.getText())));
}
}
});
PS:
dialButton is your Button
and numTxt is your EditText
This is a simple tutorial if you need more details.