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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:25:06+00:00 2026-05-30T18:25:06+00:00

This is only my second time using widgets, and first time using buttons on

  • 0

This is only my second time using widgets, and first time using buttons on it… or anything other than just TextViews in general.

So basically all I have is a widget… When I click it it doesn’t do anything and it never updates. Why? Confused… 😛

So, here is my WidgetAct onUpdate code:

@Override
public void onUpdate(Context c, AppWidgetManager awm, int[] appWidgetIds){
    Log.i("IN","onUpdate");
    RemoteViews rv = new RemoteViews(c.getPackageName(),R.layout.widget);

    Intent twitter_intent = new Intent(c,TwitterUpdate.class);
    twitter_intent.setAction(ACTION_WIDGET_TWITTER);

    Intent fb_intent = new Intent(c,FBUpdate.class);
    fb_intent.setAction(ACTION_WIDGET_FB);

    //Intent curr = new Intent(c,WidgetAct.class);
    //curr.setAction(ACTION_WIDGET_WA);

    PendingIntent twitter_pi = PendingIntent.getActivity(c, 0, twitter_intent, 0);
    PendingIntent fb_pi = PendingIntent.getActivity(c,0,fb_intent,0);

    rv.setOnClickPendingIntent(R.id.tweet, twitter_pi);
    rv.setOnClickPendingIntent(R.id.fb, fb_pi);

    awm.updateAppWidget(appWidgetIds, rv);
}

Now here is my manifest (or the important part):

 <receiver android:name="WidgetAct">
        <intent-filter>
            <action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
            <action android:name="com.laytproducts.IN.WidgetAct.ACTION_WIDGET_FB" />
            <action android:name="com.laytproducts.IN.WidgetAct.ACTION_WIDGET_TWITTER" />
        </intent-filter>
        <meta-data android:name="android.appwidget.provider"
            android:resource="@xml/winfo"/>
    </receiver>

Here is my xml for the widget provider:

<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
android:minWidth = "220dp"
android:minHeight = "72dp"
android:updatePeriodMillis="0"
android:initialLayout="@layout/widget">

Here is my layout:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:id="@+id/linearLayout1" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical">
<FrameLayout android:background="@drawable/inwidget" android:id="@+id/frameLayout1" android:layout_width="wrap_content" android:layout_height="wrap_content">
    <RelativeLayout android:id="@+id/relativeLayout1" android:layout_width="fill_parent" android:layout_height="fill_parent">
        <ImageButton android:scaleType="fitXY" android:src="@drawable/twitterlogo" android:layout_marginTop="17dp" android:id="@+id/tweet" android:layout_marginLeft="20dp" android:layout_width="40dp" android:layout_height="40dp"></ImageButton>
        <ImageButton android:scaleType="fitXY" android:src="@drawable/facebooklogo" android:layout_marginLeft="5dp" android:id="@+id/fb" android:layout_toRightOf="@+id/tweet" android:layout_alignTop="@+id/tweet" android:layout_alignBottom="@+id/tweet" android:layout_width="40dp" android:layout_height="40dp"></ImageButton>
    </RelativeLayout>

</FrameLayout>

Kind of a lot of code… but I literally have NO reason to believe that I broke something XD… but that is because my widget knowledge is minimal.

Hopefully its a small mistake I over looked.
Thanks all,
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-30T18:25:07+00:00Added an answer on May 30, 2026 at 6:25 pm

    According to the explanation in the SDK document, the onUpdate() method is designed to respond to the ACTION_APPWIDGET_UPDATE broadcast, which will be sent in conditions below:

    Sent when it is time to update your AppWidget.
    This may be sent in response to a new instance for this AppWidget provider having been instantiated, the requested update interval having lapsed, or the system booting.

    In your code, you set the action com.laytproducts.IN.WidgetAct.ACTION_WIDGET_FB, so the onUpdate() won’t be called. I haven’t used getActivity in widget, but I have used getBroadcast and it works well.

    PendingIntent fb_pi = PendingIntent.getBroadcast(c,0,fb_intent,0);
    

    I think you should handle your click event in the onReceive() method. Please note that the AppWidgetProvider extends from BroadcastReceiver, so only onReceive() will be called(in the onReceive() in the source code of AppWidgetProvider, onUpdate() is called inside. That’s why we have onUpdate()). You should do something like:

    @Override
    public void onReceive(Context context, Intent intent) {
        super.onReceive(context, intent);
        String action = intent.getAction();
    
        if (action.equals("com.laytproducts.IN.WidgetAct.ACTION_WIDGET_FB")) {
               //handle your click event here
    
            }
    
    }
    

    This is what I did in my widget. Hope it helps.

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

Sidebar

Related Questions

The title seems confusing but this is my first time using ternary conditions. I've
Despite this being one of the best error messages I've ever seen (second only
I am not sure whether this only happens to me. Basically if I have
Basically, I am trying this, but this only leaves array filled with zeros .
It's not the first time I'm having this problem, and it's really bugging me.
I am trying to play a file using the MediaPlay. The first time it
Background This is only my second PyQt4 project. Developing a Windows app that has
For the second time I have this extremely anoying problem with an InputStream. This
I am having an error when using new XMLHttpRequest() for the second time in
I'm having strange results when using this two fellows because it only sort the

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.