Retrieve incoming call's phone number in Android
Use PhoneStateListener
. It has an onCallStateChanged
handler; one of the supplied arguments you'll get is a String
containing the incoming phone number.
Your overridden method in CustomPhoneStateListener
should be called onCallStateChanged()
(and not onCallStateChange()
).
This would have been spotted by the Java compiler if you would have had the @Override
annotation, like you have for onReceive()
.