Search code examples
androidbroadcastreceivermanifest

Broadcast receiver for POWER_CONNECTED


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


Solution

  • 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>