Hello everyone,
I am facing problem to start background service on boot. My service runs without problems if started from anywhere else, but on boot, crashes immediately. Below is my BroadcastReceiver class;
namespace WSTests.Droid
{
[BroadcastReceiver(Enabled = true)]
public class BootComplete : BroadcastReceiver
{
public override void OnReceive(Context context, Intent intent)
{
try
{
if (intent.Action.Equals(Intent.ActionBootCompleted))
{
Toast.MakeText(context, "Received intent!", ToastLength.Long).Show();
Intent i = new Intent(context, typeof(SimpleService));
i.AddFlags(ActivityFlags.NewTask);
context.StartActivity(i);
}
}
catch (Exception ex)
{
throw ex;
}
}
}
}
I have attached sample project as well for more details. I will appreciate for some help.