版权声明:本文为博主原创文章,未经博主允许不得转载。
首先新建AIDL文件,ITelephony.aidl。注意包名为com.android.internal.telephony,不可更改,此时需要重新rebuild project才能正常使用。
总体效果图:如下
废话不多说,咱还是直接上代码吧:
首先布局文件:activity_phonestate
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_phonestate"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="黑名单"
android:textColor="#0e0e0e"
android:textSize="25dp" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical">
<EditText
android:id="@+id/et_phone_et"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3"
android:ems="10"
android:hint="请输入黑名单号码"
android:inputType="phone">
<requestFocus />
</EditText>
<Button
android:id="@+id/bt_contact"
android:layout_width="wrap_content"
android:layout_height="40dp"
and