android - 试图让一个安卓应用程序调用一个号码

标签 android eclipse

我想让我正在创建的应用程序打开拨号器并使用“seq”变量中的字符序列发送调用。

我尝试时遇到错误。这是我的代码。

public void sendCall(View v){
    EditText phoneNumberText=(EditText)findViewById(R.id.phoneNumberText);
    EditText topUpValueText=(EditText)findViewById(R.id.topUpValueText);
    EditText passCodeText=(EditText)findViewById(R.id.passCodeText);
    Integer phoneNumber=Integer.parseInt(phoneNumberText.getText().toString()),topUpValue=Integer.parseInt(topUpValueText.getText().toString()),passCode=Integer.parseInt(passCodeText.getText().toString());
    String seq="*195*4000*" + passCode.toString() + "*868" + phoneNumber.toString() + "*" + topUpValue.toString() + "#";
    Uri number = Uri.parse(seq);
    Intent callIntent = new Intent(Intent.ACTION_DIAL, number);

最佳答案

您可以调用以下格式的号码:"tel:123456789"

如果您想调用电话(ACTION_CALL 而不是 ACTION_DIAL),您必须需要此权限:

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

在您的 list 文件中。

关于android - 试图让一个安卓应用程序调用一个号码,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21680059/

相关文章:

android - 是否可以通过调用 Canvas.drawText() 来显示多色文本?

eclipse - 在 Eclipse 中安装 Crystal 报表

eclipse - 如何自动化测试图形(基于 eclipse)桌面应用程序?

android - 如何在 Android Studio 中自动实现建议?

android - android什么时候开始布局?

android - Android Content Provider 权限定义是否违反了 DRY 规则?

java - 如何在登录后重定向处于不同 Activity 的 2 个不同用户?

java - 如何从eclipse中调用jar包中的主类?

android - Failed to create BuildConfig class 错误信息在eclipse

android - 在 android studio 中成功构建应用程序后如何解决此问题