I would like to make a phone call from an application.
Is it possible to restrict the options only to call from the built-in phone application, not to show Viber, Skype or Whatsapp as options?
Here is my code:
Intent i = new Intent(Intent.ACTION_DIAL);
i.setData(Uri.parse("tel:"+ adapter.getItem(position).getContent()));
startActivity(Intent.createChooser(i, getString(R.string.call_number)));
I would like to look like this:
and not like this (if I have installed Viber and Skype):
I try with this code:
public static Intent callfromDefaultDialer(Context ctxt, String no) {
Intent i = new Intent();
i.setAction(Intent.ACTION_CALL);
i.setData(Uri.parse("tel:" + no));
PackageManager pm = ctxt.getPackageManager();
List<ResolveInfo> list = pm.queryIntentActivities(i, 0);
for (ResolveInfo info : list) {
String pkgnam = info.activityInfo.packageName;
if (pkgnam.toLowerCase().equals("com.android.phone")) {
i.setClassName(pkgnam, info.activityInfo.name);
return i;
}
}
return i;
}
and this opens Skype as a choice also I don't know why?
You can use the ACTION_CALL Intent flag
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phone));
startActivity(intent);
But that is no more the right choice.
You need to ask for direct phone access permission in manifest.
<uses-permission android:name="android.permission.CALL_PHONE" />
If you use only this two line of code you will have the dialer and not Skype.
Don't create a chooser, just go straight ahead with the default dialer intent.
Check also at the default phone dialer application in your phone, is this Skype?
Moreover you shold also check if the GSM Networks is available.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.