首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何发送激活代码,如*777#到拨号器使用意图?

如何发送激活代码,如*777#到拨号器使用意图?
EN

Stack Overflow用户
提问于 2019-03-06 20:50:44
回答 2查看 85关注 0票数 2

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

代码语言:javascript
运行
复制
    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();
    }
EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2019-03-06 20:55:07

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

票数 3
EN

Stack Overflow用户

发布于 2019-03-06 20:57:47

**使用:**

代码语言:javascript
运行
复制
String enCodedHash = Uri.encode("#");

String number = "*151*1" + enCodedHash;

Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:"+ number));
startActivity(callIntent);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/55023559

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档