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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:31:26+00:00 2026-05-23T19:31:26+00:00

So basically my Widget updates, according to my LogCat, and the TextView in my

  • 0

So basically my Widget updates, according to my LogCat, and the TextView in my Widget’s Layout is not. It updates when it first starts, but what I am trying to do is update it artificially using an intent after a BrocastReceiver. The intent works fine, the onUpdate runs after the onReceive, but the text is not updated. I have a feeling it has to do with the fact that a different context, AppWidgetManager, or appWidgetIds are being used.

Here are my methods:

String sent = "0";

@Override
public void onReceive(Context context, Intent intent){
    String action = intent.getAction();
    if(action != null && action.equals("27")){
        Log.i("Updating", "UPDATING WIDGET");
        sent = intent.getStringExtra("Sent");
        onUpdate(context,AppWidgetManager.getInstance(context),
                new int[]{0});
    }
    super.onReceive(context, intent);
}


@Override
public void onUpdate(Context context, AppWidgetManager appWidgetManager,
        int[] appWidgetIds){
    Log.i("Widget","onUpdate");
    String begin = "Sent ";
    String end = " Texts Since Last Visit";
    final int N = appWidgetIds.length;
    for(int i = 0 ; i < N; i++){
        int widgetId = appWidgetIds[i];

        Intent intent = new Intent(context,History.class);
        PendingIntent pi = PendingIntent.getActivity(context, 0, intent, 0);

        RemoteViews views = new RemoteViews(context.getPackageName(),
                R.layout.widget_layout);

        views.setOnClickPendingIntent(R.id.LLwidget, pi);
        Log.i("Widget","Sent: " + sent);
        views.setTextViewText(R.id.SentTextView, begin + sent + end);
        appWidgetManager.updateAppWidget(widgetId, views);
    }
}

Manifest:

 <receiver android:name="MyWidgetProvider">
        <intent-filter>
            <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
        </intent-filter>
        <meta-data android:name="android.appwidget.provider"
            android:resource="@xml/widget_info"/>
    </receiver>

widget_info:

<?xml version="1.0" encoding="utf-8"?>
<appwidget-provider
  xmlns:android="http://schemas.android.com/apk/res/android" 
  android:updatePeriodMillis="30000" 
  android:initialLayout="@layout/widget_layout" 
  android:minHeight="72dip" 
  android:minWidth="146dip">

</appwidget-provider>

I think that is all the necessary information considering I know for sure that the intent works and the onUpdate runs.

Hopefully someone can help me because this is my first attempt at a widget and my brain is a little frazzled because of lack of sleep over this.
Thanks,
Brandon

  • 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-23T19:31:27+00:00Added an answer on May 23, 2026 at 7:31 pm

    You are passing in 0 as an app widget ID. More than likely, that is not a valid app widget ID. Either use an appropriate app widget ID (e.g., one you put in an extra of the Intent you attach to the click event) or use the version of updateAppWidget() that does not take an app widget ID.

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

Sidebar

Related Questions

I'm trying to create a widget (which is basically an iframe) that would have
I am trying to build a quick search box. it is basically a widget.
I am using the jQueryUI dialog widget in a website I'm developing. Basically, the
I wrote a small program to test accessing a widget parent's slot. Basically, it
Basically, something better than this: <input type=file name=myfile size=50> First of all, the browse
Basically I am trying to restart a service from a php web page. Here
Basically, I'm trying to tap into the Soap pipeline in .NET 2.0 - I
Basically I'm trying to accomplish the same thing that mailto:bgates@microsoft.com does in Internet Explorer
I am using the sortable widget to re-order a list of items. After an
I have a slider-like widget which is basically, a div of sub-divs containing some

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.