This question was asked several times but none of the solutions are working for me. I am on kitkat(4.4.4)/Nexus5. Below are solutions I tried
1)Based on How to detect incoming calls, in an Android device? solution, I tried to retrieve the number from "extras". But intent.getExtras.getString always returns null
2)Based on Get phone number of present incoming and outgoing call solution, I tried to read from the log, but "cur.getString(0)", always returns null
I am NOT using TelephonyManager any where in my code (though few in above links seem to be using telephonymanager). I am using BroadcastReceiver. My code is below. I ended up trying above 2 solutions, because I am getting null value(callingNumber) in my callback below.
public class MyPhoneStateListener extends PhoneStateListener {
//blah blah
public void onCallStateChanged(int state, String callingNumber)
{
//callingNumber is always null, unfortunately
}
}