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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:28:52+00:00 2026-06-09T10:28:52+00:00

I’m implementing a Widget that has a ConfigurationActivity, and must stay compatible to Eclair(2.1).

  • 0

I’m implementing a Widget that has a ConfigurationActivity, and must stay compatible to Eclair(2.1).

The documentation about AppWidgetProviders onUpdate method states clearly that:

… .However, if you have declared a configuration Activity, this method is not called when the user adds the App Widget, but is called for the subsequent updates. It is the responsibility of the configuration Activity to perform the first update when configuration is done. (See Creating an App Widget Configuration Activity below.)

Unfortunately this isn’t true (at least for my Nexus S with JellyBean). In Fact onUpdate gets called before onCreate of my ConfigurationActivity triggers. I want to know, if there is similar behavior on other phones, and if it is possible to prevent the onUpdate call inside my Provider?

My Workaround is to store a flag in SharedPreferences inside my WidgetConfigurationActivity with that particular AppWidgetId. If it isn’t there, I can assume that the ConfigurationActivity wasn’t called first. This works, but is in my point of View really ugly. If I cannot prevent onUpdate from triggering, is there a better solution?

  • 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-09T10:28:53+00:00Added an answer on June 9, 2026 at 10:28 am

    Yes, onUpdate() gets called when you add a widget on the homescreen.
    See here:

    http://developer.android.com/reference/android/appwidget/AppWidgetProvider.html

    http://developer.android.com/reference/android/appwidget/AppWidgetManager.html#ACTION_APPWIDGET_UPDATE

    I’m not sure if there is a way to not trigger it when a widget is created. But you can stop it from triggering again by setting the “updatePeriodMillis” field in Widget Info XML file to 0 or just leaving it blank.

    Another way would be to store the widget IDs somewhere. Now whenever a new widget is added, in your Receiver class, check if the ID already exists or not. If it does not exist (meaning a new widget), then dont execute any code. Also, remove widget ID from your records whenever a widget is deleted. Since there is a possibility that you removed a widget, then later added a new widget which has the same ID as the old one.

    Hope that helps!

    EDIT:
    In the onReceive() method in your Receiver class, do this:

    public void onReceive(Context context, Intent intent) {
        // TODO Auto-generated method stub
    
        int appWidgetId = intent.getIntExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, AppWidgetManager.INVALID_APPWIDGET_ID);
        if( appWidgetId != AppWidgetManager.INVALID_APPWIDGET_ID )
        {
            super.onReceive(context, intent);
        }
    
    }
    

    When a widget is first selected from the Widgets list, its appWidgetId will be equal to INVALID_APPWIDGET_ID until it is added on the home screen. Since “super.onReceive()” calls the onUpdate() method when a widget is selected, onUpdate() will not be called the first time.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
In my XML file chapters tag has more chapter tag.i need to display chapters

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.