Reputation: 696
If a user has an alternative dialer installed (i.e. more than one dialer on their phone) an implicit intent will ask for a choice between them.
My issue is that I am wishing to set an explicit intent for the default dialer within code as I do not wish this selection to be displayed but all action forwarded to the inbuilt/default dialer whatever that may be.
This is my current (implicit) intent code:
Log.i(TAG, "Sending: "+Number);
Intent dialIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:"+ Number));
//called from outside of an android.app.Activity Context
dialIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(dialIntent);
How can I force an explicit intent?
I tried this - but I think I'm on the wrong track here...
dialIntent.setComponent((new ComponentName("com.android.internal.telephony","com.android.internal.telephony.ITelephony.class")));
Many thanks.
Upvotes: 1
Views: 700
Reputation: 122
Well rather than calling the default dialer, you should call the component in custom phone dialer that handles calls. Becoz you can't set default activity for an action programmatically
Upvotes: 0
Reputation: 4985
I think you're on the right track with a hard-coded URI (or whatever they're called), but it's a brittle approach, to say the least.
What you're trying to do goes against Android's open, flexible design, defeats the purpose of the Intent system, and would be downright hostile to users. I know I'd be more than a little miffed if one app forced the lame default dialer on me ;)
Why do you need to use the inbuilt dialer?
My advice: use the default Intent. Advise your users to opt for the inbuilt dialer, but try to support those who choose to use another.
Upvotes: 1