解决方法
做一个广播接收器说ServiceReceiver在Manifest中分配它的动作.
<receiver android:name=".ServiceReceiver" > <intent-filter> <action android:name="android.intent.action.PHONE_STATE" /> </intent-filter> </receiver>
将PhoneStateListener添加到TelephonyManager,PhoneStateListener具有覆盖onCallStateChanged()和Incoming number参数.而已.
ServiceReceiver.Java
public class ServiceReceiver extends BroadcastReceiver { @Override public void onReceive(final Context context,Intent intent) { TelephonyManager telephony = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE); telephony.listen(new PhoneStateListener(){ @Override public void onCallStateChanged(int state,String incomingNumber) { super.onCallStateChanged(state,incomingNumber); System.out.println("incomingNumber : "+incomingNumber); } },PhoneStateListener.LISTEN_CALL_STATE); } }