I\'m writing a cross-platform solution in Xamarin, and am about to add a mother project for 3rd-partyu integration (e.g., other Android-parties that want to integrate with m
├── DroidMainApp
│ └── MyBroadcastReceiver (A Project level reference to DroidMainApp)
├── ADifferentApp
com.sushihangover.toaster
com.sushihangover.toaster.receiver
Enabled
and Exported
[BroadcastReceiver(Name = "com.sushihangover.toaster.receiver", Enabled = true, Exported = true)]
public class Toaster : BroadcastReceiver
{
public override void OnReceive(Context context, Intent intent)
{
Toast.MakeText(context, "Go make some toast", ToastLength.Long).Show();
Log.Info("SO", "Go make some toast");
}
}
BroadcastReceiver
:Explicit
Intentvar toasterIntent = new Intent();
toasterIntent.SetClassName("com.sushihangover.toaster", "com.sushihangover.toaster.receiver");
var pendingIntent = PendingIntent.GetBroadcast(this, 0, toasterIntent, PendingIntentFlags.CancelCurrent);
var alarmService = (AlarmManager)GetSystemService(Context.AlarmService);
alarmService.SetRepeating(AlarmType.Rtc, 1000, 60000, pendingIntent);