Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 978789
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T04:06:50+00:00 2026-05-16T04:06:50+00:00

I have a widget that shows some data fetched from the Internet. I may

  • 0

I have a widget that shows some data fetched from the Internet. I may have multiple widgets visible on the screen, each displaying some data, partly the same as the other widgets.

From time to time I re-fetch the data from the Internet and update the widget views.

I’ve modeled this in an MVC style: I have a model which I can invoke a “re-fetch-data” on, and which the views listen on.

My questions:

A) Is it wise to let my model be a singleton?

B) Can I rely on that all widgets are served by the same AppWidgetProvider? Or may some of my widgets get served by a different AppWidgetProvider instance? Or, more generally: Is there any guarantee that there will be only one instance of my AppWidgetProvider?

If there is only one instance of my AppWidgetProvider, then I could use an instance variable here for the model, and pass either my AppWidgetProvider or the model around where needed. Perhaps a better option?

C) In the AppWidgetProviders onUpdate method, can I be sure that the same “context” object is passed as argument each invocation?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T04:06:50+00:00Added an answer on May 16, 2026 at 4:06 am

    Is it wise to let my model be a
    singleton?

    Considering you can’t have static data in an AppWidgetProvider, I would say a singleton is extremely unsafe. You need to use a persistent store, such as a file or database.

    Can I rely on that all widgets are
    served by the same AppWidgetProvider?

    It will be the same class. It most definitely will not be the same instance, unless you are doing some really evil stuff, like trying to have an everlasting service.

    Or may some of my widgets get served
    by a different AppWidgetProvider
    instance?

    Yes.

    Or, more generally: Is there any guarantee that there will be only one instance of my AppWidgetProvider?

    There is a guarantee there will NOT be only one instance of your AppWidgetProvider. “If this BroadcastReceiver was launched through a tag, then the object is no longer alive after returning from this function.”

    In the AppWidgetProviders onUpdate
    method, can I be sure that the same
    “context” object is passed as argument
    each invocation?

    I do not think that is a safe assumption.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a few small flash widgets that stream .mp3 audio from an
Let's say that I have a widget that displays summary information about how many
I have a UI widget that needs to be put in an IFRAME both
We have a UI widget on our main UI that uses JavaScript to respond
I have a ListView on a page that displays a list of widgets. When
I have tried to use some of the widgets in JQuery UI on an
I am making a custom widget that I would like to use in multiple
I have some JavaScript code that dynamically injects an iframe in a given HTML
I am using a fictional example for this. Say, I have a Widget class
I have a JavaScript widget which provides standard extension points. One of them is

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.