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>