Search code examples
javaandroidphone-numberphone-call

How to write a phone number for calling in android but not make the call


I want to have an action onClick on a button in some activity that just writes a phone number in the agenda screen, but not call it. I have to let the user decide if he wants to call or not.

What I have found by now is this code, that works perfectly, but it's not really what I need. With this code, when I click the button, it calls the selected

private OnClickListener callToAction = new OnClickListener() {

    @Override
    public void onClick(View v) {
        Log.d(TAG, "onClick sticky from homepage.");
        Intent callIntent = new Intent(Intent.ACTION_CALL);
        callIntent.setData(Uri.parse("tel:*123"));
        startActivity(callIntent);
    }
};

Solution

  • Use Intent.ACTION_DIAL to open the dialer instead of connecting the call.