如何在安卓上运行 USSD 命令?

有没有人知道如何运行USSD命令来检查手机的信用余额(号码是*123#)并得到结果(信用余额)做进一步处理?谢谢

has anyone know how to runs USSD command for checking phone's credit balance (the number is *123#) and get the result (the credit balance) for further processing?? thankss

推荐答案

您可以在 Android 设备中运行 USSD 代码,但您将无法在应用程序中解析结果.将来可能会将此功能添加到 Android SDK 中,但现在,您必须寻找替代方案.

You can run USSD codes in Android devices but you would be unable to parse the result in your application. This feature might be added to the Android SDK in the future but for now, you would have to look for an alternative.

USSD 可以使用简单的调用意图来运行.见例子:

USSD can be run using simple Call intents. See Example:

String ussdCode = "*" + "123" + Uri.encode("#");
startActivity(new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + ussdCode)));

如评论中所述,还需要通话权限

as mentioned in the comments phone call permission is also required

<uses-permission android:name="android.permission.CALL_PHONE" /

相关文章