Forum Xamarin.Forms

Execute block of code at certain time every day

I developed a Xamarin forms app that can update by pressing a button. Now I want to execute that code every day at certain hour for example 8:00 Am
how can I achieve that ??

Answers

  • LeonLuLeonLu Member, Xamarin Team Xamurai

    Now I want to execute that code every day at certain hour for example 8:00 Am

    In the xamarin Android, you can use AlarmManager to achieve it with following code.

     AlarmManager alarmManager= (AlarmManager) GetSystemService(AlarmService);
     alarmManager.Set(AlarmType.RtcWakeup, JavaSystem.CurrentTimeMillis()+(time*1000),pi);       
    

    Here is an realted document about it.

    https://camposha.info/xamarin-android-alarmmanager-schedule-toast-message/


    Xamarin forums are migrating to a new home on Microsoft Q&A!
    We invite you to post new questions in the Xamarin forums’ new home on Microsoft Q&A!
    For more information, please refer to this sticky post.

  • JohnHardmanJohnHardman GBUniversity admin

    @LeonLu

    What approaches are available on iOS and UWP?

Sign In or Register to comment.