Hello PaoloMossa-0994,
Welcome to our Microsoft Q&A platform!
I am developing an App with Xamarin on Android.
When building a Xamarin.Forms project on Android platform, all pages are shown on the MainActivity. To close the app, you could call the Finish method of MainActivity using DependencyService.
[assembly:Dependency(typeof(DroidImplementation))]
namespace TestApplication1.Droid
{
public class DroidImplementation : MyInterface
{
public void QuitApplication()
{
var activity = MainActivity.Instance as Activity;
activity.Finish();
}
}
}
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
public static MainActivity Instance { get; set; }
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
Instance = this;
...
}
}
Best Regards,
Jarvan Zhang
If the response is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
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.