如何使用意图向拨号程序发送* 777#之类的激活码?

时间:2019-03-06 12:50:44

标签: java android

我想使用意图将代码* 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();
    }

2 个答案:

答案 0 :(得分:3)

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

答案 1 :(得分:0)

**使用此方法:**

String enCodedHash = Uri.encode("#");

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

Intent callIntent = new Intent(Intent.ACTION_CALL);
callIntent.setData(Uri.parse("tel:"+ number));
startActivity(callIntent);