当用户从我的应用程序拨打号码时出现问题,并且如果用户设置将另一个应用程序作为默认应用程序(Skype,Viber等...),则它不会为此打开默认设备调用应用程序设备,但依次打开其他应用(Skype,Viber等)。我想要的是我的应用程序可以打开默认设备拨号程序吗? 请帮我!谢谢!
答案 0 :(得分:0)
我已经找到问题的解决方案: 在您的共享代码处,您只能从您的Android平台特定项目中访问该代码。在以下位置添加代码
: Intent intentCall = new Intent(Intent.ActionDial);
intentCall.SetData(Uri.Parse($"tel:{phone}"));
intentCall.AddFlags(ActivityFlags.ReorderToFront);
PackageManager pm = Forms.Context.PackageManager;
IList activities = pm.QueryIntentActivities(intentCall, PackageInfoFlags.MatchDefaultOnly);
foreach (ResolveInfo item in activities)
{
if (item.ActivityInfo.ToString().ToLower().Contains("com.android.phone"))
{
intentCall.SetPackage("com.android.phone");
break;
}
else if (item.ActivityInfo.ToString().ToLower().Contains("call"))
{
intentCall.SetPackage("com.android.server.telecom");
break;
}
}
Forms.Context.StartActivity(intentCall);
或在以下时间使用代码
Intent intentCall = new Intent(Intent.ActionCall);
intentCall.SetData(Uri.Parse($"tel:{phone}"));
intentCall.AddFlags(ActivityFlags.ReorderToFront);
if (Build.VERSION.SdkInt >= BuildVersionCodes.Lollipop || Build.VERSION.SdkInt >= BuildVersionCodes.LollipopMr1)
{
intentCall.SetPackage("com.android.server.telecom");
}
else
{
intentCall.SetPackage("com.android.phone");
}
Forms.Context.StartActivity(intentCall);