Sample code for Android Widget (with Background Service) with Xamarin Forms or Maui

Frank 1 Reputation point
2022-08-16T05:04:16.657+00:00

I have an Android App with a Widget that uses JobIntentService to update the widget every 30 minutes, like in the official sample https://learn.microsoft.com/en-us/samples/xamarin/monodroid-samples/simplewidget/

That used to work fine, but in newer android sdk JobIntentService is deprecated and does no longer work reliable. What service do I need for the backgroundservice? WorkManager or something else? Is there any recent sample code like a weather widget, that works on Android 5-13 but without the deprecated JobItentService?

Xamarin
Xamarin
A Microsoft open-source app platform for building Android and iOS apps with .NET and C#.
5,287 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Leon Lu (Shanghai Wicresoft Co,.Ltd.) 67,781 Reputation points Microsoft Vendor
    2022-08-17T08:39:58.88+00:00

    Hello,

    What service do I need for the backgroundservice? WorkManager or something else?

    You can use WorkManager to execute tasks in background.

    Is there any recent sample code like a weather widget, that works on Android 5-13 but without the deprecated JobItentService?

    No, there are no these samples like weather widget, but Xamarin has a blog about using WorkManager. Please refer to Getting Started With WorkManager

    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