Source:
listener = new PhoneStateListener()
{
@Override
public void onCallStateChanged(int state, String incomingNumber) {
super.onCallStateChanged(state, incomingNumber);
Toast toast = Toast.makeText(getApplicationContext(), incomingNumber, Toast.LENGTH_LONG);
toast.show();
}
};
((TelephonyManager)getSystemService(TELEPHONY_SERVICE)).listen(listener , PhoneStateListener.LISTEN_CALL_STATE )
Hi,
I am using this permission code android.permission.READ_PHONE_STATEto receive a message with a toast, including the number of the call started. My problem is that the incoming number is empty, no matter if the call is outgoing or incoming, toasts appear, but are empty.
I saw some solutions for this, but the solution was to get the number in a completely different way, and I want to know if my code can be used for my needs.
Thanks for the advice,
Adam.
source
share