android - 为什么我不能使用 Uri 类进行调用?

标签 android android-intent uri phone-call

我正在使用以下代码从我的 android 代码调用电话。但它似乎不起作用。所有这些代码所做的只是在调用应用程序中显示电话号码,但它不打电话。

Uri call=Uri.parse("tel:9008765750");//that's an example phone number
Intent ii= new Intent(Intent.ACTION_VIEW,call);
startActivity(ii);

最佳答案

改变

Intent ii= new Intent(Intent.ACTION_VIEW,call);

Intent ii= new Intent(Intent.ACTION_CALL,call);

并添加权限<uses-permission android:name="android.permission.CALL_PHONE" />

Intent.ACTION_VIEW用于Display the data to the user.

所以当你使用 tel:Intent.ACTION_VIEW它只会显示数字。

Intent.ACTION_CALL用于Perform a call to someone specified by the data.

关于android - 为什么我不能使用 Uri 类进行调用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24803899/

相关文章:

android - 使用方法 -canvas.drawBitmap(bitmap, src, dst, paint)

android - 如何在 Android 中以编程方式获取 "CompileSdkversion"

使用 Intent 的 Activity 中的 Android Activity

Android 2.2 MediaPlayer 在一个 SHOUTcast URL 上工作正常,但在另一个 URL 上却不行

java - 列出android中下载目录中的文件

android - 如何清除 v2 google map 中的所有标记?

android - 为 Google Play 服务清除数据时的 Intent 操作

android - 如何在Android中没有Intent且没有任何 View 窗口的情况下拍照

java - 如何将 Uri 值传递给 bundle 值

json - Ansible:如何在 JSON 中打印数字而不是字符串 - 模块 uri