0

I want to register the receiver in code. In my manifest I have this:

<receiver android:name=".MyReceaver">
<intent-filter>
<action android:name="android.intent.action.POWER_CONNECTED" />
</intent-filter>
</receiver>

I read this startActivity() from BroadcastReceiver but it didn't works, the onReceive method doesn't get called, if I register in code it works great.

what is the problem ? why it doesn't works ? I register the broadcast receiver in code and it works perfectly but when it is registered in the manifest it doesn't. Does anybody had registered this kind of receiver in manifest ? or maybe the @Gubbel is just wrong and this can't be registered in manifest. Maybe is like the screen_on/off which must be registered in code and can't be registered in manifest.

any tips or explanations why it is not working is welcomed Thanks

Edit: sorry I must be blind, I didn't see the action_ part

Community
  • 1
  • 1
Lukap
  • 31,523
  • 64
  • 157
  • 244
  • 2
    The link you gave already contains the answer. Use action android:name="android.intent.action.ACTION_POWER_CONNECTED" – Vladimir Ivanov Oct 07 '11 at 18:08
  • Check out this question: http://stackoverflow.com/questions/2104372/android-event-action-power-connected-is-not-sent-to-my-broadcastreceiver it does exactly what you are trying to do – slayton Oct 07 '11 at 18:10

1 Answers1

1

I copied wrong action string...

this is the right receiver

<receiver android:name=".MyReceaver">
<intent-filter>
<action android:name="android.intent.action.ACTION_POWER_CONNECTED" />
</intent-filter>
</receiver>
Lukap
  • 31,523
  • 64
  • 157
  • 244