BigCAT41
BigCAT41

Reputation: 93

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);   
    }
}); 

Upvotes: 1

Views: 421

Answers (1)

superfell
superfell

Reputation: 19040

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"));

Upvotes: 2

Related Questions