Hello,
Welcome to our Microsoft Q&A platform!
Have you added the following permission in file AndroidManifest.xml
?
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
I tried to create a new demo to achieve this function , and it works properly in my device (Google Pixel 8.1).
The main code is:
1.create a BootReceiver
[BroadcastReceiver(Enabled = true, DirectBootAware = true, Exported = true)]
[IntentFilter(new[] { Intent.ActionBootCompleted }, Priority = (int)IntentFilterPriority.HighPriority)]
public class BootReceiver : BroadcastReceiver
{
public override void OnReceive(Context context, Intent intent)
{
Intent i = new Intent(context, typeof(MainActivity));
i.AddFlags(ActivityFlags.NewTask);
context.StartActivity(i);
}
}
2.added the following permission in file AndroidManifest.xml
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
Note: we should change receiver android:name=
into above receiver we created (BootReceiver
)
Best Regards,
Jessie Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.