【问题标题】:Why ACTION_CALL not working on Android 11为什么 ACTION_CALL 无法在 Android 11 上运行
【发布时间】:2022-01-14 11:40:37
【问题描述】:

为什么我运行这段代码时会出现这句话(to place a call enter a valid number)?

                Intent intent = new Intent(Intent.ACTION_CALL);
                intent.setData(Uri.parse("tel:" + "#1234#"));
                startActivity(intent);

但是,如果您将数字从 "#1234#" 更改为 "123456789",它可以正常工作 为什么不接受 (#) 符号?

知道我添加了

       <uses-permission android:name="android.permission.CALL_PHONE" />

在 AndroidManifest.xml 中

注意:它仍然适用于低于 Android 11 的版本,并且可以毫无问题地接受 (#) 符号。

【问题讨论】:

  • 我找到了解决方案 Intent intent = new Intent(Intent.ACTION_CALL); intent.setData(Uri.parse("tel:"+ Uri.encode("#1234#")));开始活动(意图);

标签: android android-intent call phone-call android-phone-call


【解决方案1】:

你试过用“%”替换“#”吗?

Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:" + Uri.encode("#1234#")));
startActivity(intent);

这应该可以解决您的问题。

【讨论】:

  • 欢迎 先生 你没明白我的意思 我想创建一个按钮 当用户点击它 直接拨打这个号码 (#1234#) 因为这个号码 ( #1234#),如果用户在我的国家拨打它,他知道电信运营商(Vodafone)(SIM)还剩多少分钟。
  • 是的,我确实理解,并且按照您的要求替换这些字符。你试过了吗?
  • 是的,我试过了,但没用
  • 我找到了解决方案 Intent intent = new Intent(Intent.ACTION_CALL); intent.setData(Uri.parse("tel:"+ Uri.encode("#1234#")));开始活动(意图);
  • 太棒了!我已经为未来的读者更新了答案!
猜你喜欢
  • 2021-01-02
  • 1970-01-01
  • 2012-09-17
  • 1970-01-01
  • 2021-12-11
  • 1970-01-01
  • 1970-01-01
  • 2021-12-09
  • 1970-01-01
相关资源
最近更新 更多