widget - Send a public broadcast from an AppWidget in Android -
I have a widget for a music player and want to send the broadcast by pushing different buttons. What do I want to do, when a button is pushed, the widget sends a public broadcast to another broadcast broadcaster so that it can handle different tasks.
In my activity class with the broadcast receiver:
Private Broadcast Receiver Broadcast Receiver = New Broadcast Receiver () {@ Override Public Records on Revive (Reference Reference, Intent Intent) {string action = intent. Gate action (); If (action.equals (Constants.ACTION_NEXT)) {log d. ("Receiver", "ACTION_NEXT"); }}}; @ Override Safe void onStart () {super.onstart (); IntentFilter Filter = New Intent Filter (); // Widget Action filter.addAction (Constants.ACTION_NEXT); Register receiver (broadcast receiver, new intent filter (filter)); }
In my widget:
Update on Public Zero (Reference Reference, AppWidgetManager appWidgetManager, int [] appWidgetIds) {Remote Visual View = New Remote View (Ref. GetPackageName (), R.layout.widget); Pending Vertical Vertical = Pending Intent.TetBreckcast (Reference, 0, New Intent (Stable Action_NXT), 0); Views.setOnClickPendingIntent (R.id.WidgetNextButton, pendingIntent); AppWidgetManager.updateAppWidget (Appevance ID, View);
Any help or other solutions are greatly appreciated!
EDIT: Forgot to mention my actual problem: Broadcasting never received broadcast
Comments
Post a Comment