android - 如何通过点击号码调用电话

标签 android phone-call

我有一个包含数字的 ListView 。当您单击该号码时,我希望它调用电话,并显示一个带有两个选项的确认弹出窗口 - "is"和“否”。当我调用以下代码时,它可以工作,但它离开了我的应用程序 - 它应该在应用程序内进行调用,并且,如果用户单击“否”,则应出现上一个屏幕,如果用户单击"is",则应调用该屏幕数字。然后,通话结束后,应该返回到上一个屏幕。有什么想法吗?

Intent sIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:123434543"));    
startActivity(sIntent);

最佳答案

试试这个::

private void callDialog() {
    try {

        dismissProgressDialog();

        TextView textView = new TextView(this);
        textView.setGravity(Gravity.CENTER);
        textView.setText("Would u like to do call?");
        textView.setPadding(10, 10, 10, 10);
        textView.setTextColor(Color.WHITE);
        textView.setTextSize(18);

        AlertDialog.Builder dialog = new AlertDialog.Builder(BusinessList.this);
        dialog.setTitle("");
        dialog.setView(textView);

        dialog.setPositiveButton("Yes", new android.content.DialogInterface.OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {

                startActivity(new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + callNo)));

            }
        });
        dialog.setNegativeButton("No", new android.content.DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {

            }
        });
        dialog.show();

    } catch (Exception e) {
        e.printStackTrace();
    }
}

当你打电话时请不要完成 Activity 。
如果你想要不同的请解释更多。

关于android - 如何通过点击号码调用电话,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8709613/

相关文章:

android - Android 中的 Applozic 视频通话

android - 如何在Kotlin中实现List <data class>(子列表)的可拆分的实现?

java - 使 Realm gradle 插件与 android studio 3 一起使用

android - 有什么方法可以在 Android 上制作自定义 Spannables 吗?

java - 重启手机取消共享首选项

ios - 是否可以在 iPhone 模拟器上模拟通话?

android - 将音频流式传输到 Android 电话

IOS调用号码并输入代码

android - 如何为来电和去电录音?

iOS 通话录音应用