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

  • SEARCH
  • Home
  • 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 6998499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:25:08+00:00 2026-05-27T20:25:08+00:00

I have a widget running under android and I would like for it to

  • 0

I have a widget running under android and I would like for it to update itself when the user clicks a button on the widget.

For some reason, the onReceive method is never called when a button is clicked after i install the widget.

I have a onUpdate method like this in my AppWidgetProvider class:

@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
                    int[] appWidgetIds) {

        super.onUpdate(context, appWidgetManager, appWidgetIds);

        for (int i = 0; i < appWidgetIds.length; ++i) {

              final RemoteViews rv = 
new RemoteViews(context.getPackageName(), R.layout.appwidget_provider);       

              final Intent nextIntent = 
new Intent(context, TestAppWidgetProvider.class);
              nextIntent.setAction(TestAppWidgetProvider.NEXT_ACTION);
              nextIntent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetIds[i]);

              final PendingIntent refreshPendingIntent = 
PendingIntent.getBroadcast(context, 0,
                                nextIntent, PendingIntent.FLAG_UPDATE_CURRENT);
              rv.setOnClickPendingIntent(R.id.next, refreshPendingIntent);

              appWidgetManager.updateAppWidget(appWidgetIds[i], rv);
         }
}

And then in my on receive i have a method that looks like:

@Override
public void onReceive(Context ctx, Intent intent) {

    super.onReceive(ctx, intent);

    final String action = intent.getAction();

    if (action.equals(PREV_ACTION)) {

        Toast.makeText(ctx, "Previous clicked..", Toast.LENGTH_SHORT).show();
    } else if (action.equals(NEXT_ACTION)) {

        Toast.makeText(ctx, "Next was clicked..", Toast.LENGTH_SHORT)
                .show();
    }
    else {
        Toast.makeText(ctx, "Other action..", Toast.LENGTH_SHORT).show();
    }           
}

I have this in my manifest file too:

<receiver android:name="com.test.android.widget.TestAppWidgetProvider" >
      <intent-filter >
          <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
      </intent-filter>
      <intent-filter >
          <action android:name="com.test.android.widget.PREV" />
      </intent-filter>
      <intent-filter >
          <action android:name="com.test.android.widget.NEXT" />
      </intent-filter>
      <meta-data
            android:name="android.appwidget.provider"
            android:resource="@xml/appwidget_info" />
</receiver>

After I install the widget and click on the next button, the onReceive method is never called for some reason…

  • 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-27T20:25:09+00:00Added an answer on May 27, 2026 at 8:25 pm

    Fixed it, turned out to be trivial.

    It was because onReceive wasn’t even being called on widget creation, so the event listener wasn’t setup.

    Added some of the code that was in onReceive (setting the setOnClickPendingIntent etc) to a function which is called when the widget configure activity is ready to update the widget.

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

Sidebar

Related Questions

I currently have a Pylons application running with a basic user system set-up. I
I have some COD files that I have developed using the Widget toolkit for
I have used gallery widget to display downloaded images.But unfortunately I am running into
I have a *.ui definition I'm loading and running. A certain sub-widget there has
I'm running into a ClassCastException when trying to integrate the Panel widget from android-misc-widgets
I'm making modifications to the Android 4.0 launcher and I have been running into
I have a jqueryui autocomplete combo-box widget in which once the user selects something
I'd like to have an xterm-compatible virtual terminal running inside a Python app. I'll
I have a widget that acts as a launcher on the home screen. How
I have this widget: $this->setWidget('slug', new sfWidgetFormDoctrineChoice(array('model' => 'MyTable', 'method' => 'myMethod', 'key_method' =>

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.