Hello,
For how to get Android device rooted in MAUI, you can refer to the steps below.
Step 1. Create a static RootedHelper
class in Platforms/Android
folder.
public static class RootedHelper
{
public static bool checkRootMethod()
{
// If the device is rooted, these paths and files can be accessed.
String[] paths = { "/system/app/Superuser.apk", "/sbin/su", "/system/bin/su", "/system/xbin/su", "/data/local/xbin/su", "/data/local/bin/su", "/system/sd/xbin/su",
"/system/bin/failsafe/su", "/data/local/su", "/su/bin/su"};
foreach (var s in paths)
{
if (File.Exists(s))
{
return true;
}
}
return false;
}
}
Step 2. You could invoke this method in MAUI using the following code.
#if ANDROID
var rooted = RootedHelper.checkRootMethod();
if (rooted)
{
Console.WriteLine("rooted");
}
else
{
Console.WriteLine("Not rooted");
}
#endif
Best Regards,
Alec Liu.
If the answer is the right solution, 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.