简体   繁体   English

Android应用呼叫客户服务号码

[英]Android app calling customer service number

What is the best option to implement a function that allow the user to call the customer service number in app? 实施允许用户在应用程序中拨打客户服务号码的功能的最佳选择是什么?

In iOS, this is easy, just say UIApplication.shared.open("tel:xxxxxxx") will do. 在iOS中,这很简单,只需说UIApplication.shared.open("tel:xxxxxxx") It will show a small dialog to allow the user to call or not, and shows the number to the user clearly so the user knows this is a free number. 它将显示一个小对话框,允许用户呼叫或不呼叫,并清楚地向用户显示该号码,以便用户知道这是一个免费号码。

However in Android I need to add android.permission.CALL_PHONE , but this is a dangerous permission, when the user install the app they will see a message "this app may cost you money". 但是,在Android中,我需要添加android.permission.CALL_PHONE ,但这是一个危险的权限,当用户安装该应用时,他们会看到一条消息“此应用可能会花费您的钱”。

In API 23+ we can request permissions at runtime, but the document says we still need to add the user permission to request it at runtime. 在API 23+中,我们可以在运行时请求权限,但是文档说我们仍然需要添加用户权限才能在运行时请求权限。

So, what is the best option we can have? 那么,我们可以拥有的最佳选择是什么? We don't want the user being scared by a harmless feature. 我们不希望用户被无害功能吓到。

As described in documentation, CALL_PHONE permission is used for making calls from app itself. 如文档中所述,CALL_PHONE权限用于从应用程序本身发出呼叫。 It's possible to hide it from user and yes, it's dangerous. 可以向用户隐藏它,是的,这很危险。

CALL_PHONE Allows an application to initiate a phone call without going through the Dialer user interface for the user to confirm the call. CALL_PHONE允许应用程序在不通过Dialer用户界面的情况下发起电话呼叫,以使用户确认呼叫。

But you may always make calls using dialer without any extra permissions. 但是,您可能总是在没有任何额外权限的情况下使用拨号程序拨打电话。

Intent callIntent=new Intent(Intent.ACTION_DIAL);
callIntent.setData(Uri.parse("tel:xxxxxxx"));
startActivity(callIntent);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM