1. layout File
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".MainActivity" > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello_world" /> <EditText android:id="@+id/phoneNumber" android:layout_width="fill_parent" android:layout_height="wrap_content" android:phoneNumber="true" /> <Button android:id="@+id/BtnCall" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/call" /> </LinearLayout>
2. Dialing procedure
MainActivity = String hm = (hm. trim (). length ()! = 0 = Intent ("android. intent. action. CALL", Uri. parse ("tel:" +, "the phone number cannot be blank"
3. AndroidManifest. xml file to apply for the permission to call.
<! -- Add the permission for dialing out --> <uses-permission android: name = "android. permission. CALL_PHONE"> </uses-permission>
The running effect is as follows: