https://bugzilla.novell.com/show_bug.cgi?id=667406
https://bugzilla.novell.com/show_bug.cgi?id=667406#c0 Summary: Event'd BroadcastReceiver would be nice Classification: Mono Product: MonoDroid Version: SVN Platform: Other OS/Version: Other Status: NEW Severity: Enhancement Priority: P5 - None Component: Class Libraries AssignedTo: [email protected] ReportedBy: [email protected] QAContact: [email protected] Found By: --- Blocker: --- User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.10 (KHTML, like Gecko) Chrome/8.0.552.237 Safari/534.10 Having a class included like this would be nice (Not sold on the EventBroadcastReceiver name): using System; using System.Collections.Generic; using System.Linq; using System.Text; using Android.App; using Android.Content; using Android.OS; using Android.Runtime; using Android.Views; using Android.Widget; namespace Blah { public class EventBroadcastReceiver : BroadcastReceiver { public event Action<Context, Intent> Receive; public override void OnReceive(Context context, Intent intent) { if (this.Receive != null) this.Receive(context, intent); } public void Register(Context context, string action) { context.RegisterReceiver(this, new IntentFilter(action)); } public void Register(Context context, string action, string dataType) { context.RegisterReceiver(this, new IntentFilter(action, dataType)); } public void Register(Context context, IntentFilter filter) { context.RegisterReceiver(this, filter); } public void Unregister(Context context) { context.UnregisterReceiver(this); } } } Then we could implement in an activity like this: using System; using System.Collections.Generic; using System.Linq; using System.Text; using Android.App; using Android.Content; using Android.OS; using Android.Runtime; using Android.Views; using Android.Widget; namespace MyApp { [Activity(Label = "My Activity")] public class BroadcastActivity : ListActivity { EventBroadcastReceiver broadcastReceiver; protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); broadcastReceiver = new EventBroadcastReceiver(); broadcastReceiver.Receive += (Context context, Intent intent) => { //Get new data //Refresh list this.ListView.RefreshDrawableState(); }; } protected override void OnResume() { base.OnResume(); broadcastReceiver.Register(this, "com.myapp.broadcastactivity.SOME_ACTION"); } protected override void OnPause() { broadcastReceiver.Unregister(this); base.OnPause(); } } } Reproducible: Always -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the QA contact for the bug. _______________________________________________ mono-bugs maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-bugs
