Reputation: 654
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);
}
};
Upvotes: 0
Views: 818
Reputation: 11
You need to use other Intent Action for that.
Try Intent.ACTION_DIAL
http://developer.android.com/reference/android/content/Intent.html#ACTION_DIAL
or Intent.ACTION_VIEW
http://developer.android.com/reference/android/content/Intent.html#ACTION_VIEW
Example from Intent documentation:
ACTION_VIEW tel:123 -- Display the phone dialer with the given number filled in. Note how the VIEW action does what what is considered the most reasonable thing for a particular URI. ACTION_DIAL tel:123 -- Display the phone dialer with the given number filled in.
Upvotes: 1
Reputation: 8395
Use Intent.ACTION_DIAL
to open the dialer instead of connecting the call.
Upvotes: 2