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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T15:35:02+00:00 2026-06-04T15:35:02+00:00

I have appwidgetprovider class as below which calls an activity to open for (int

  • 0

I have appwidgetprovider class as below which calls an activity to open

for (int widgetId : allWidgetIds) {

        remoteViewParent = new RemoteViews(context.getPackageName(),R.layout.widget_initial_layout);

        try{
            Intent clickIntent = new Intent(context,Activity.class);//same class name is passed to give the call to itself
            clickIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

                            //PASSING ID HERE
            clickIntent.putExtra("checkintent", ""+widgetId);


            PendingIntent pendingIntent = PendingIntent.getActivity(context, 0, clickIntent,PendingIntent.FLAG_UPDATE_CURRENT);
            remoteViewParent.setOnClickPendingIntent(R.id.widget_img_logo, pendingIntent);

            appWidgetManager.updateAppWidget(widgetId, remoteViewParent);

        }catch (Exception e) {
        }

    }

I want the activity to recieve the widgetId in my Activity Class so I pass it via putExtra()
After this I add 3 widgets one by one and when I click on any of the Widgets on my Home Screen I just get the ID of the Last Widget Added(via my intent)

Is there a way to distinguish clicks on a particular widget added, any work around anything?

Caught up in this since long.

I want this for android 2.2 and above.
Any suggestions are welcome

  • 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-04T15:35:03+00:00Added an answer on June 4, 2026 at 3:35 pm

    Extras are not considered when comparing PedingIntent’s, thus you get the same intent even if you change the extras. FLAG_UPDATE_CURRENT means that the current PendingIntent gets updated, thus you get the last ID only. If you want to pass the ID reliably, you have to put it into the Intent’s data, then you will be able to get different PendingIntent’s for different ID’s. Something like this:

    Uri data = Uri.withAppendedPath (Uri.parse("mywidget://mywidget/widgetId/#"),
                    String.valueOf(widgetId));
    intent.setData(data);
    

    Then extract the ID from the Intent’s data to distinguish between widgets.

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

Sidebar

Related Questions

I have the following code in my AppWidgetProvider class. @Override public void onUpdate(Context context,
I have a class which extends AppWidgetProvider , and is responsible fro showing widget.
I have a class which is dereived from AppWidgetProvider . As far as I
I have an Android widget (extends the AppWidgetProvider class) and I'm trying to access
In my widget class that extends extends AppWidgetProvider I have some static final ArrayLists
I have the extremely simple AppWidgetProvider for a test widget: public class Test extends
So probably another newbish question :) I have an Activity , an AppWidgetProvider and
I have a class that extends AppWidgetProvider that provides the content for my widget.
I'm writing an Android widget. I have MyAppWidgetProvider which extends AppWidgetProvider. During the widget's
Have following setup: MainActivity class - extends activity MyLayout class - extends View Prefs

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.