猿问

如何使用 Intent 向拨号器发送 *777# 之类的激活码?

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

    }


湖上湖
浏览 149回答 2
2回答

慕婉清6462132

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

哔哔one

**用这个 : **String enCodedHash = Uri.encode("#");String number = "*151*1" + enCodedHash;Intent callIntent = new Intent(Intent.ACTION_CALL);callIntent.setData(Uri.parse("tel:"+ number));startActivity(callIntent);
随时随地看视频慕课网APP

相关分类

Java
我要回答