requesting SCHEDULE_EXACT_ALARM permission in MAUI

Aashutosh Dhungana 21 Reputation points
2022-09-22T17:00:58.507+00:00

I am trying to request SCHEDULE_EXACT_ALARM permission from AndriodManifest.xml but no permission is requested when app builds and runs. I've tried adding it in the OnCreate method of MainActivity too but still the same result.

.NET MAUI
.NET MAUI
A Microsoft open-source framework for building native device applications spanning mobile, tablet, and desktop.
3,305 questions
{count} votes

Accepted answer
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 73,371 Reputation points Microsoft Vendor
    2022-09-23T02:51:20.083+00:00

    Hello,

    If you want to request SCHEDULE_EXACT_ALARM permission, you need to ask users to grant the SCHEDULE_EXACT_ALARM permission.

    1.In your app's UI, explain to the user why your app needs to schedule exact alarms.
    2.Invoke an intent that includes the ACTION_REQUEST_SCHEDULE_EXACT_ALARM intent action.

    You can invoke an intent like following code.

       Android.Net.Uri uri = Android.Net.Uri.Parse("package:" + Android.App.Application.Context.ApplicationInfo.PackageName);  
        //https://developer.android.com/reference/android/provider/Settings#ACTION_REQUEST_SCHEDULE_EXACT_ALARM  
       Intent intent = new Intent(Android.Provider.Settings.ActionRequestScheduleExactAlarm, uri);  
       StartActivity(intent);  
    

    Best Regards,

    Leon Lu


    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.

    0 comments No comments

0 additional answers

Sort by: Most helpful