@WendyZang very kindly provided the answer to the original question, which is that you unfortunately cannot launch the Android settings app (let alone drill into the settings specifically for your own app) using the Xamarin.Essentials Launcher.
Instead, you must use a Dependency Service with platform specific implementations. To help others who run into the same sort of issue, I wanted to add in a complete solution of setting up a Dependency Service on both iOS and Android, which navigates not only to the OS's settings app, but specifically into the settings for your app:
In your cross-platform project, the interface might look something like the following. You will need to pass in your app's bundle-id (eg, com.myCompany.myApp
):
namespace MyCoolMobileApp.Services.DependencyServices
{
public interface ISettingsAppLauncher
{
void LaunchSettingsApp(string appBundleId);
}
}
In Android, your implementation could be like the following (note that I am using James Montemagno's CurrentActivity plugin):
using System.Diagnostics;
using Android.Content;
using Plugin.CurrentActivity; // https://github.com/jamesmontemagno/CurrentActivityPlugin
using MyCoolMobileApp.Droid.Services.DependencyServices;
using MyCoolMobileApp.Services.DependencyServices;
using Xamarin.Forms;
[assembly: Dependency(typeof(SettingsAppLauncher_Android))]
namespace MyCoolMobileApp.Droid.Services.DependencyServices
{
public class SettingsAppLauncher_Android : ISettingsAppLauncher
{
public void LaunchSettingsApp(string appBundleId)
{
var intent = new Intent(Android.Provider.Settings.ActionApplicationDetailsSettings);
intent.AddFlags(ActivityFlags.NewTask);
var uri = Android.Net.Uri.FromParts("package", appBundleId, null);
intent.SetData(uri);
CrossCurrentActivity.Current.AppContext.StartActivity(intent);
}
}
}
Last but not least, the iOS implementation would be:
using System.Diagnostics;
using Foundation;
using MyCoolMobileApp.iOS.Services.DependencyServices;
using MyCoolMobileApp.Services.DependencyServices;
using UIKit;
using Xamarin.Forms;
[assembly: Dependency(typeof(SettingsAppLauncher_iOS))]
namespace MyCoolMobileApp.iOS.Services.DependencyServices
{
public class SettingsAppLauncher_iOS : ISettingsAppLauncher
{
public void LaunchSettingsApp(string appBundleId)
{
var url = new NSUrl($"app-settings:{appBundleId}");
UIApplication.SharedApplication.OpenUrl(url);
}
}
}