Android 开发总结之获取来电号码
2010-02-22 16:21:00 来源:WEB开发网核心提示:case TelephonyManager.CALL_STATE_OFFHOOK:Log.d(TAG, "OFFHOOK");break;}}}public class CustomPhoneStateListener extends PhoneStateListener {private stat
case TelephonyManager.CALL_STATE_OFFHOOK:
Log.d(TAG, "OFFHOOK");
break;
}
}
}
public class CustomPhoneStateListener extends PhoneStateListener {
private static final String TAG = "CustomPhoneStateListener";
@Override
public void onCallStateChanged(int state, String incomingNumber){
Log.v(TAG, "WE ARE INSIDE!!!!!!!!!!!");
Log.v(TAG, incomingNumber);
switch(state){
case TelephonyManager.CALL_STATE_RINGING:
Log.d(TAG, "RINGING");
break;
case TelephonyManager.CALL_STATE_IDLE:
Log.d(TAG, "IDLE");
break;
case TelephonyManager.CALL_STATE_OFFHOOK:
Log.d(TAG, "OFFHOOK");
break;
}
}
}
Java代码
- <?xml version="1.0" encoding="utf-8"?>
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
- package="com.xjgz"
- android:versionCode="1"
- android:versionName="1.0">
- <application android:icon="@drawable/icon" android:label="@string/app_name">
- <receiver android:name=".CustomBroadcastReceiver" >
- <intent-filter>
- <action android:name="android.intent.action.PHONE_STATE" />
- </intent-filter>
- </receiver>
- </application>
- <uses-permission android:name="android.permission.READ_PHONE_STATE" />
- <uses-sdk android:minSdkVersion="7" />
- </manifest>
更多精彩
赞助商链接