首先给打电话的TextView谈出一个Dialog,
String title1 = "请选择"; String[] items1 = new String[]{"打电话", "发送短信","取消"}; new AlertDialog.Builder(FellowActivity.this) .setTitle(title1) .setItems(items1, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { switch(which){ case 0: Intent intent1 = new Intent(FellowActivity.this,CallActivity.class); startActivity(intent1); break; case 1: Intent intent2 = new Intent(FellowActivity.this,FasongActivity.class); startActivity(intent2); break; case 2: Toast.makeText(FellowActivity.this, "已取消,请重新选择", Toast.LENGTH_SHORT).show(); break; } } }).show();
跳转到另一个页面之后,写一个EditText,一个Button按钮
case R.id.button_call: if (edphone.getText().toString().trim() == null || edphone.getText().toString().trim().equals("")) { Toast.makeText(CallActivity.this, "对不起,电话不能为空", Toast.LENGTH_SHORT).show(); return; } else if (edphone.getText().toString().trim() != null && !(edphone.getText().toString().trim().equals(""))) { Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + edphone.getText().toString().trim())); if (ActivityCompat.checkSelfPermission(CallActivity.this, Manifest.permission.CALL_PHONE) != PackageManager.PERMISSION_GRANTED) { return; } startActivity(intent); } break;