Ahh thats not the way the samples do it, that kinda looks more right too, I will try that.
2009/11/15 Mark Murphy <[email protected]> > Paul Townsend wrote: > > Hi I am having trouble with broadcast receivers, I want to use the > > media_button broadcast so I can call a method on my service, I have > > tried putting the receiver inside the service class so I can call the > > method but that just says that the receiver is enclosed, but not > > static. If I create a new receiver class then I would have to bind a > > service connection from the receiver and that don't seem right, so > > what am I doing wrong I tried searching for it but cant seem to find > > an answer. > > If I am going to register a BroadcastReceiver in Java code (vs. via the > manifest), I tend to just make it an anonymous inner class: > > BroadcastReceiver onBatteryChanged=new BroadcastReceiver() { > public void onReceive(Context context, Intent intent) { > // something useful here > } > }; > > You can see an example of this for receiving ACTION_BATTERY_CHANGED > broadcast Intents here: > > > http://github.com/commonsguy/cw-advandroid/tree/master/SystemEvents/OnBattery/ > > The same techniques should work for you for your media button. > > -- > Mark Murphy (a Commons Guy) > http://commonsware.com | http://twitter.com/commonsguy > > Android 1.6 Programming Books: http://commonsware.com/books > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to [email protected] > To unsubscribe from this group, send email to > [email protected]<android-developers%[email protected]> > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

