Receiving "call from null" from Android System - Google Pixel Community
Android incoming or outgoing call phone number is null - Stack Overflow
broadcastreceiver - Incoming number is null after ending the call in android PIE 9 - Stack Overflow
9.0 pie - "call_state_offhook list.size()==0 number is null" when I call someone with my Samsung Galaxy S9 - Android Enthusiasts Stack Exchange
There are two different "types" of phone state receivers, receivers that have Manifest.permission.READ_CALL_LOG permission and receivers that don't.
If a receiver doesn't have the Manifest.permission.READ_CALL_LOG permission, it will be called for all state changed once, without the EXTRA_INCOMING_NUMBER extra.
If a receiver does have that above permission, like in your case, it will be called for every state changed twice, one without the EXTRA_INCOMING_NUMBER permission, and another time with it.
Since you have this code:
if (lastState == state) {
return;
}
in your onCallStateChanged method, you're basically skipping the second call, and thus losing the EXTRA_INCOMING_NUMBER info.
If you're sure you have the READ_CALL_LOG permission, you can try skipping the duplicated receiver call without that extra completely (however note that there's a difference between getting a "null" value for that extra which means a private number call, and not getting that extra at all), like so:
String stateStr = intent.getExtras().getString(TelephonyManager.EXTRA_STATE);
if (!intent.getExtras().containsKey(TelephonyManager.EXTRA_INCOMING_NUMBER)) {
Log.i("Call receiver", "skipping intent=" + intent + ", extras=" + intent.getExtras() + " - no number was supplied");
return;
}
String number = intent.getExtras().getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
See the official docs at: https://developer.android.com/reference/android/telephony/TelephonyManager#ACTION_PHONE_STATE_CHANGED
In Android 9, the number is included in intent extras under key incoming_number
I've been thinking about this, and figured it might be a decent discussion on this sub. I'm always "connected" to people all the time, the past year or so I have made good habit of using "do not disturb" on my phone. I'm hitting a some sort of a point where with work, friends, etc, I just for the love of god what to "unplug" and have 0 way of contacting me. I don't even want to be able to check if you texted me, I don't even want to see the missed calls.
I used to have another number on our company plan. But Jesus H Christ, telemarkets and scam callers still find it. I want to be left the fuck alone sometimes.
First thought, obvious, chuck your phone. I've done this, but honestly, sometimes I just want to browse reddit, read whatever, steam some music, something to decompress, and inevitably I see the missed calls and texts. I know it's there, so it's impossible to ignore.
I'm hoping some of you can sympathize with my perspective, and there's no malcontent with it. I just need to be left the fuck alone sometimes but I also want an internet connection.... Nothing is better than driving way out into nowhere just blasting some music on Spotify and not thinking about shit, until you get a fucking call.
I really wish there was some sort of firewall service I could port my number to. I wish I could have "push 1 for this, push 2 for that" before my phone even sees a call. I wish I could actually go offline on my own terms.
I'm just going to leave that as that. I really would like to see what everyone else has to say. I would like to see ideas how to fix this problem. In fact, I bet some business plan could be made. Seriously, if someone charged $X/Mo and I could just not have texts and phone calls come to my phone for X period of time, holy shit, I would buy that instantly.
How do you all stay sane while also wanting to reap the benefits of being online?
Edit: basically, ideally, I just want a number that can't be callled or texted by anyone. How can I do this?
Sometime last week my phone started receiving this "call from null: answering this will end your current call" notification every single second of the day, it literally doesn't go away.
Can't answer it, can't decline it, can't change the volume while the "call" is ongoing, can't listen to music or videos because the calling notification overrides everything else.
Haven't downloaded anything in a while, too, just to put it out there.
Those last days it started to "disappear" for a couple hours per day, but it always triggers after someone calls me, and sometimes at random as well.
Thank you for reading and hopefully answering soon. :)