Search code examples
androidandroid-intentphone-numberphone-call

Launch the Android dialer with a specific number


The code I have works perfectly but all it does is launch the dialer. What I want it do is to be able to launch the dialer with a specific number. How can I do that?

bu5.setOnClickListener(new OnClickListener() {

    public void onClick(View v) {
        //open the phone dialer on clicking the button
        Intent intent = new Intent(Intent.ACTION_DIAL);
        startActivity(intent);   
    }
}); 

Solution

  • You need to set the tel: uri with the number into the intent, add this before the startActivity line.

    intent.setData(Uri.parse("tel:1231231234"));