Jam*_*mal 5 android action android-intent android-dialer
在我的Android应用程序中,我想在用户单击按钮时自动拨打电话.我使用下面的代码集来实现这个功能
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:911"));
startActivity(intent);
Run Code Online (Sandbox Code Playgroud)
在我的AndroidManifest.xml我也添加了这个 <uses-permission android:name="android.permission.CALL_PHONE" />权限.
但它只是用给定的911号码打开拨号盘,而不是拨打电话.
至少在美国,911是紧急号码.CALL_PHONE不足以称呼这个号码.有一个单独的权限(CALL_PRIVILEGED?),一个普通SDK应用程序无法持有的权限.
更新:我记得正确.以下是该权限的Android 6.0平台清单条目:
<!-- @SystemApi Allows an application to call any phone number, including emergency
numbers, without going through the Dialer user interface for the user
to confirm the call being placed.
<p>Not for use by third-party applications. -->
<permission android:name="android.permission.CALL_PRIVILEGED"
android:protectionLevel="signature|privileged" />
Run Code Online (Sandbox Code Playgroud)