Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何添加按钮呼叫特定号码_Android - Fatal编程技术网

Android 如何添加按钮呼叫特定号码

Android 如何添加按钮呼叫特定号码,android,Android,我想在我的应用程序中添加一个按钮,允许手机拨打特定号码。 我还想添加消息服务。请尝试使用此代码拨打特定号码 call.setOnClickListener(new View.OnClickListener() {//here call is the button public void onClick(View v) { try { String Numb = "tel:" + repphone;// repphone is

我想在我的应用程序中添加一个按钮,允许手机拨打特定号码。
我还想添加消息服务。

请尝试使用此代码拨打特定号码

call.setOnClickListener(new View.OnClickListener() {//here call is the button
        public void onClick(View v) {
            try {
                String Numb = "tel:" + repphone;// repphone is phonr num
                Intent intent = new Intent(Intent.ACTION_CALL, Uri
                        .parse(Numb));
                startActivity(intent);
            } catch (Exception e) {
                // Modules.showLongMessage(contact.this, e.getMessage());
            }
        }
    });

请尝试使用此代码拨打特定号码

call.setOnClickListener(new View.OnClickListener() {//here call is the button
        public void onClick(View v) {
            try {
                String Numb = "tel:" + repphone;// repphone is phonr num
                Intent intent = new Intent(Intent.ACTION_CALL, Uri
                        .parse(Numb));
                startActivity(intent);
            } catch (Exception e) {
                // Modules.showLongMessage(contact.this, e.getMessage());
            }
        }
    });

请参阅拨打电话的示例。

请参阅拨打电话的示例。

在button.onClickListener中编写以下代码

String url = "tel:3334444";
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse(url));

在button.onClickListener中编写以下代码

String url = "tel:3334444";
Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse(url));

在清单文件中设置权限:

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

在清单文件中设置权限:

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