How do I programmatically "restart" an Android app in.Net maui? #17630
Unanswered
Sanji-1109
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Description
How do I programmatically "restart" an Android app in.Net maui?
I have been trying to restart the application when the system reboot in .net maui app
AndroidManifest.xml
BootBroadcastReceiver.cs
using global::Android.App;
using global::Android.Content;
[BroadcastReceiver(Enabled = true, DirectBootAware = true,Exported = true)]
[IntentFilter(new[] { Intent.ActionBootCompleted })]
public class BootBroadcastReceiver : BroadcastReceiver
{
public override void OnReceive(Context context, Intent intent)
{
Intent i = new Intent(context, typeof(MainActivity));
i.AddFlags(ActivityFlags.NewTask);
context.StartActivity(i);
}
}
[Activity(Theme = "@style/Maui.SplashTheme", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation | ConfigChanges.UiMode | ConfigChanges.ScreenLayout | ConfigChanges.SmallestScreenSize | ConfigChanges.Density)]
public class MainActivity : MauiAppCompatActivity
{
BootBroadcastReceiver receiver;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
receiver = new BootBroadcastReceiver();
}
}
I already tried all answers related to this in stackoverflow it is not working.
Environment: visual studio 2022 .NET MAUI version: MAUI 7.0
Steps to Reproduce
No response
Link to public reproduction project repository
No response
Version with bug
7.0.92
Is this a regression from previous behavior?
Yes, this used to work in .NET MAUI, No, this is something new, Not sure, did not test other versions
Last version that worked well
Unknown/Other
Affected platforms
iOS, Android
Affected platform versions
No response
Did you find any workaround?
No response
Relevant log output
No response
Beta Was this translation helpful? Give feedback.
All reactions