0

In manifest xml:

<receiver android:label="BGTasksBroadcast" android:name=".BGTasksBroadcast">
    <intent-filter>
        <action android:name="android.intent.action.SCREEN_ON" />
        <action android:name="android.intent.action.REBOOT" />
    </intent-filter>
</receiver>

In broadcast receiver:

public void onReceive(Context context, Intent intent) {
    // TODO Auto-generated method stub
    Log.d("Log", "BROADCAST RECEIVER " );
}

When I launch the app I am not seeing the log "BROADCAST RECEIVER ".

Cœur
  • 37,241
  • 25
  • 195
  • 267
Cintu
  • 913
  • 2
  • 16
  • 32
  • I need to call the service in the background. So i am using broadcast reciever to call that. But i am not seeing any log placed in Broadcast reciever. I dono how to debug this – Cintu Dec 30 '11 at 13:07

1 Answers1

0

If you lock and unlock your device di you see it ?

android.intent.action.SCREEN_ON
android.intent.action.REBOOT

are different from app launch.

Android does not seem to support manifest-registered receivers for cases where they really do not want to start up a new process. For example, you will see the same effect with the battery info actions (e.g., BATTERY_LOW). (cc CommonsWare) you have to start them from the code, see here: android.intent.action.SCREEN_ON doesn't work as a receiver intent filter

Community
  • 1
  • 1
vieux
  • 23,887
  • 3
  • 26
  • 26
  • Ya but i am not seeing the logs even if i close the simulator and run once again.. – Cintu Dec 30 '11 at 13:05
  • You use reboot, if you need boot you should use: ACTION_BOOT_COMPLETED – vieux Dec 30 '11 at 13:07
  • SCREEN_ON is enough to call the broadcast reciever rite? – Cintu Dec 30 '11 at 13:08
  • i am not seeing the log when i lock or unlock the simulator – Cintu Dec 30 '11 at 13:11
  • Android does not seem to support manifest-registered receivers for cases where they really do not want to start up a new process. For example, you will see the same effect with the battery info actions (e.g., BATTERY_LOW). (cc CommonsWare) you have to start them from the code, see here: http://stackoverflow.com/questions/2575242/android-intent-action-screen-on-doesnt-work-as-a-receiver-intent-filter – vieux Dec 30 '11 at 13:12
  • Then what is the best approach for calling the service in the background even if my app not launched? – Cintu Dec 30 '11 at 13:18
  • I would use ACTION_BOOT_COMPLETED to start the others from java code. – vieux Dec 30 '11 at 13:19
  • BOOT_COMPLETED is working fine now. After installing the app the user needs to reboot the device for activating to my service? – Cintu Dec 30 '11 at 13:26