【问题标题】:Android make a call with "#" on the endAndroid 以“#”结尾拨打电话
【发布时间】:2012-02-13 09:40:48
【问题描述】:

我在此论坛中找到了此代码,但我无法在电话号码中使用此字符(#/u0023)。

我知道这个问题已经被问过了,但你可能知道“Go SMS Pro”应用程序,这个应用程序实际上可以拨打这个号码。现在我想问你是否知道如何管理它。

try {
     Intent callIntent = new Intent(Intent.ACTION_CALL);
     String number = "tel:*100#"; /This is the number
     callIntent.setData(Uri.parse(asd));
     startActivity(callIntent);

     TelephonyManager tManager = (TelephonyManager) 
     getSystemService(Context.TELEPHONY_SERVICE);
     PhoneStateListener listener = new PhoneStateListener();
     tManager.listen(listener, PhoneStateListener.LISTEN_CALL_STATE);
} catch (ActivityNotFoundException activityException) {
     Log.e("telephony-example", "Call failed", activityException);
}

【问题讨论】:

  • 你有没有尝试转义字符\

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


【解决方案1】:

网址编码。

String number = "tel:*100%23";
callIntent.setData(Uri.parse(asd));

或者,如果您需要更通用的方法(例如,如果您的数字发生变化...) - 使用 URLEncoder 对 URI 的数据部分进行编码。

String number = "tel:"+ URLEncoder.encode("*100#");
....

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多