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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:39:54+00:00 2026-05-27T04:39:54+00:00

I want to code an app that displays some information in an widget, which

  • 0

I want to code an app that displays some information in an widget, which should be updated from time to time. From time to time means, that I use an alarm timer to trigger a peroidic update. So heres the problem: intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS); is null for the broadcast receivers intent.

Here’s my widget provider:

public class MyWidgetProvider extends AppWidgetProvider {
    public void onUpdate(Context context, AppWidgetManager appWidgetManager, int[] appWidgetIds) {
        final int N = appWidgetIds.length;      
    for(int i=0; i<N; i++) {
            int widgetId = appWidgetIds[i];         
            RemoteViews rViews = new RemoteViews(context.getPackageName(), R.layout.widget_layout);         
            Intent intent = new Intent(context.getApplicationContext(), TrafficService.class);
            intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS, appWidgetIds);            
            rViews.setTextViewText(R.id.TextView01, "" + System.currentTimeMillis());           
            appWidgetManager.updateAppWidget(widgetId, rViews);
        }
    }
}

and this is the BroadcastReceiver causing the problem:

public class TimeIntervalReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
// set new alarm timer (code cut out)       
        AppWidgetManager appWidgetManager = AppWidgetManager.getInstance(context.getApplicationContext());
        // PROBLEM BELOW!
        int[] appWidgetIds = intent.getIntArrayExtra(AppWidgetManager.EXTRA_APPWIDGET_IDS);     
        if(appWidgetIds == null) Log.d("TRAFFIC", "oh SHIT");
        if(appWidgetIds != null && appWidgetIds.length > 0) {
            for(int widgetId : appWidgetIds) {
                RemoteViews rViews = new RemoteViews(context.getPackageName(), R.layout.widget_layout);
                rViews.setTextViewText(R.id.TextView01, "some data");
                appWidgetManager.updateAppWidget(widgetId, rViews);
            }
        }
    }
}

Is this even solveable?

  • 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-27T04:39:55+00:00Added an answer on May 27, 2026 at 4:39 am

    When the system calls your implementation of AppWidgetProvider, it fills the intent with these extras.

    But when it calls your broadcast receiver which has nothing to do with the widget, it does not fill this extra in the intent.

    You will have to use another method to transfer the ID’s. Maybe you could fill them in the Intent which is fired as the alarm fires?

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

Sidebar

Related Questions

I have a standalone Java app that has some licensing code that I want
In my app I've got a thread which displays for some time please wait
I currently have an app that displays the time. I want to change the
We have a winform app that has been in development for some time. It
So, I am working on an app that displays some info about the current
I'm currently working on an app for the Android OS that displays some data.
I have some code that displays a checkmark as the auxiliary view of a
I have written a small android app that grabs some data and displays it
Ok, I have a winforms app and my code works fine. But I want
I want a code that when applied to text in Visual Basic 2008 it

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.