java - 如何使用 Intent 向拨号器发送 *777# 等激活码?

标签 java android

我想使用 Intent 将代码 *777# 发送到 Android 中的拨号器,但我只有一个问题 *777 关键代码将显示在拨号器上,而不是 # 如何解决此问题我是 Android 开发人员的新手,所以请帮助我解决这个问题。

    String dialler_Code = "*777#";
    Toast.makeText(this, "clicked", Toast.LENGTH_LONG)
            .show();

    // Use format with "tel:" and phoneNumber created is stored in u.

    Uri u = Uri.parse("tel:" + dialler_Code);

    // Create the intent and set the data for the intent as the phone number.

    Intent i = new Intent(Intent.ACTION_DIAL, u);
      try {
        // Launch the Phone app's dialer with a phone number to dial a call.
        startActivity(i);
    } catch (SecurityException s) {

        // show() method display the toast with exception message.
        Toast.makeText(this, s.getMessage() , Toast.LENGTH_LONG)
                .show();
    }

最佳答案

尝试使用String dialler_Code = Uri.encode("*777#");

关于java - 如何使用 Intent 向拨号器发送 *777# 等激活码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55023559/

相关文章:

java - 如何在 oracle 列中查找无效的 UTF-8 字符

Java mysql 执行更新

android - 从 firebase 查询数据

java - 在 Android 应用程序中使用属性文件时出现 NullPointerException

android - TabLayout 在 Appbar 布局内部使用时不可见

Java WeakReferences = 理解问题(使用 HornetQ JMS 实现)?

java - 当指定仅使用 wifi 时,ConnectivityManager Network 为 null

java - 如何使用JSON编写 map 文件

android - lateinit 属性绑定(bind)尚未初始化

java - 获取毫秒以显示在 android 设备中