2

i'm having a problem on android ICS (version 4) and broadcastReceiver . please help:

i'm trying to listen to a simple intent of network connectivity change . i've tried the next tutorial (with the broadcastReceiver defined in the manifest alone - the first part of the website ) : http://www.xinotes.org/notes/note/1526/ on ICS , it doesn't capture any intent , and on any other version it works just fine .

can anyone please tell me what's wrong? do i need to add a new intent filter other than the one that listens to CONNECTIVITY_CHANGE ? has google blocked listening to such intents on ICS ? are there any other new rules for ICS that have changed ?

i think that other broadcastReceivers also won't work on ICS using the manifest .

AakashM
  • 62,551
  • 17
  • 151
  • 186
android developer
  • 114,585
  • 152
  • 739
  • 1,270

1 Answers1

3

The sample code shown in that link may work, but it needs an activity. On Android 3.1+, an application is installed in a "stopped" state. While in that state, no BroadcastReceiver will work, until the user manually launches an activity from the application. The application will return to this "stopped" state if the user force-stops the application from Settings.

So, add an activity to your project, launch it once, and then see if your receiver works.

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • do you have any reference to read this info from? also , why did they do it? it's breaking the way many application might work . is it for security ? are there any BroadcastReceivers that still listen without installations ? what about bootup intents? – android developer Feb 01 '12 at 13:40
  • @androiddeveloper: "do you have any reference to read this info from?" http://developer.android.com/sdk/android-3.1.html#launchcontrols "are there any BroadcastReceivers that still listen without installations ? what about bootup intents?" no and no. – CommonsWare Feb 01 '12 at 13:49
  • oops , i meant "without running" . is it still correct? i've heard of applications that once your device is stolen , you can choose to install them using the market , and then it will tell you the position of the device and even allow you to erase the data of it . does it mean that now such applications won't be able to work (unless the thief opens them) ? – android developer Feb 01 '12 at 14:57
  • @androiddeveloper: " does it mean that now such applications won't be able to work (unless the thief opens them) ?" -- correct. – CommonsWare Feb 01 '12 at 15:03
  • thank you for all of your answers. i wonder why google decided to remove such features , even if the user specifically wanted to install an app that starts without the need to open it . i really liked the idea that even if an android device would be stolen (or just not found) you will always be able to find it . is there any way to overcome such an obstacle for such applications , or are they doomed? – android developer Feb 01 '12 at 15:37
  • I have the same query , how will I be able to know whether my phone is connected on VPN ? – Chetan Feb 20 '12 at 07:23