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 8173389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T22:08:03+00:00 2026-06-06T22:08:03+00:00

Somewhere here on Stack Overflow, I had found the following code some day which

  • 0

Somewhere here on Stack Overflow, I had found the following code some day which I adjusted to my application a bit:

private void updateWidget() {
    AppWidgetManager widgetManager = AppWidgetManager.getInstance(ctx);
    ComponentName widgetComponent = new ComponentName(ctx, MyAppWidgetProvider.class);
    int[] widgetIds = widgetManager.getAppWidgetIds(widgetComponent);
    Intent update = new Intent();
    update.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, widgetIds);
    update.setAction(AppWidgetManager.ACTION_APPWIDGET_UPDATE);
    ctx.sendBroadcast(update);
}

This should programmatically refresh all instances of the application’s widget. ctx is the Activity‘s context (this) that I set once in onCreate(). The method above is called in the Activity‘s onStop() method.

Unfortunately, when it is called, it replaces the app’s widget by other apps’ widgets (e.g. AP News) – at least for a while.

How can this happen? Is there something wrong in the code?

Thank you!

Edit #1: To point this out more clearly: I’ve already defined an interval for automatic refreshing. But in addition to that, I would like to update the widget from the Activity from time to time. This question suggests that it is possible as well.

Edit #2: I’ve just seen that the wrong widget is only shown for some seconds. After that, my own app’s widget is shown again.

  • 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-06-06T22:08:05+00:00Added an answer on June 6, 2026 at 10:08 pm

    I had some problems with widgets in the past, and have solved them. I really do not know the reason why my solution worked for me. And as it worked for Marco W., so I place it here: all I did was moved the update code to a service. When I need to update, start that service. Again, I’m not sure about that but the problems were solved.

    Thanks Marco, I got some more experiences with Android. It’s funny 🙂

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

Sidebar

Related Questions

Ok the error is showing up somewhere in this here code if($error==false) { $query
Here's my code, I know there's a small mistake somewhere but being a noob
I am working with development of an application which, among other pieces of code,
I'm not entirely sure whats happened here. I may have messed things up somewhere,
Somewhere along the line from the DB to the application, this: sauté is getting
Somewhere some guy said (I honestly do not know where I got this from),
Can some professional experienced Magento developer tell me how to accomplish the following in
As I am an impressed reader of Stack Overflow I want to ask my
I have some trouble with some inline assembly code. I know what should be
I'm trying to get some custom routing going on in Magento using the following

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.