I am trying to make a simple service which starts with device boot. Thing is that device return message \"Unfortunately, [app_name] has stopped.\"
I am struggling wi
By adding the receiver in the manifest and via the BroadcastReceiverAttribute you have two receivers in your manifest. Plus the one in your manifest will not work since it is not the MD5-based Java name that Xamarin creates by default.
1) Remove the receiver and boot permission from your manifest
2) Add your boot permissions via an attribute)
[assembly: UsesPermission(Manifest.Permission.ReceiveBootCompleted)]
3) Add the manifest entry via attributes:
[BroadcastReceiver(Enabled = true)]
[IntentFilter(new[] { Intent.ActionBootCompleted })]
public class BootBroadcastReceiver : BroadcastReceiver
1) Add the manifest entry for the boot permission
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
2) Add the receiver and use a full qualify Java class name:
<receiver android:name="com.yourpackagename.app.BootBroadcastReceiver">
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED"/>
</intent-filter>
</receiver>
3) Add a Name
parameter to the BroadcastReceiverAttribute
for the fully qualified Java class name that you used in the manifest
[BroadcastReceiver(Name = "com.yourpackagename.app.BootBroadcastReceiver", Enabled = true)]
[IntentFilter(new[] { Intent.ActionBootCompleted })]
public class BootBroadcastReceiver : BroadcastReceiver
I found another solution for this problem,
Please, be sure your BootBroadcastReceiver is present on the Yourproject.Android.csproj file
<ItemGroup>
<Compile Include="MainActivity.cs" />
<Compile Include="Provider\AppVersionProvider.cs" />
<Compile Include="Resources\Resource.Designer.cs" />
<Compile Include="Properties\BootBroadcastReceiver.cs" />
<Compile Include="others_staf" />
And see SushiHangover's answer.