Phone state revisited

2 replies [Last post]
paller's picture
Offline
Joined: 11 Apr 2010
Points: 195
0
0

A while ago I wrote a blog post about capturing android.intent.action.PHONE_STATE broadcasts and acting on the phone call state changes that this broadcast signals. The example program there is pre-1.0 and somebody wrote me a mail asking for a version that works on today's phone. I wrote one, it is attached to this post (you have to be logged to Sfonge's site to access it) and it works nicely on a 2.2 device. For example it generates the following dump for an incoming call:
D/PhoneIntentReceiver(13367): Phone intent: Intent { act=android.intent.action.PHONE_STATE cmp=aexp.phonestatereceiver/.PhoneIntentReceiver (has extras) }
D/PhoneIntentReceiver(13367): extra: state:RINGING
D/PhoneIntentReceiver(13367): extra: incoming_number:+36xxxxxxx
...
D/PhoneIntentReceiver(13367): Phone intent: Intent { act=android.intent.action.PHONE_STATE cmp=aexp.phonestatereceiver/.PhoneIntentReceiver (has extras) }
D/PhoneIntentReceiver(13367): extra: state:OFFHOOK
...
D/PhoneIntentReceiver(13367): Phone intent: Intent { act=android.intent.action.PHONE_STATE cmp=aexp.phonestatereceiver/.PhoneIntentReceiver (has extras) }
D/PhoneIntentReceiver(13367): extra: state:IDLE
The trouble is that this application does not capture any PHONE_STATE intents on my Nexus S with the shiny new 4.0.3 ICS image. At the moment I don't know if it is just one of those 4.0.3 "features" or some change in the concept. Any ideas?

Attached file: 
Róbert Bodó's picture
Offline
Joined: 15 Sep 2011
Points: 20
Quick check

Hi Gabor,

I've checked your app on my Nexus One with Android 2.3.7(CM 7.1) and on my Samsung Galaxy Nexus with stock Android 4.0.3 and it worked as you described on both devices. Maybe this is a bug in the ICS update for your Nexus S.

paller's picture
Offline
Joined: 11 Apr 2010
Points: 195
ICS+broadcast

I have received a tip at the blog post with a similar topic.
Starting with 3.1, Android applications initialize in stopped state. This means that no broadcast receiver works before you start an application component (typically Activity) manually. I have never had a Galaxy Nexus (I believe the stock firmware is 4.0.2 because the 4.0.3 OTA upgrade was not rolled out) but the Nexus S 4.0.3 behaves according to the specification. Pretty shocking discovery, actually.