Call intent in Android

前端 未结 7 1265
生来不讨喜
生来不讨喜 2020-12-10 06:16

How can I make call by pressing button? I get my number as a string from EditText. Here is my sample code:

String phone = editPhone         


        
7条回答
  •  轮回少年
    2020-12-10 06:53

    Try this

    EditText num = (EditText)findViewById(R.id.phone_number);
    String uri = "tel:" + num.trim();
    Intent intent = new Intent(Intent.ACTION_CALL, Uri.parse(uri));
    startActivity(intent);
    

提交回复
热议问题