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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T14:04:47+00:00 2026-05-23T14:04:47+00:00

I add contact pictures to a widget dynamical. This is my code for this

  • 0

I add contact pictures to a widget dynamical. This is my code for this part:

for (int x = 0; x < this.appWidgetIds.length; x++){
        int id = this.appWidgetIds[x];
        RemoteViews rv = new RemoteViews(this.context.getPackageName(), R.layout.widget);
        for (int i = 0; i < maxCount; i++){
            String lookupKey = sortedItems.get(i).getLookupKey();
            Tools.ToLog("LOOKUPKEY=" + lookupKey);
            Bitmap bmp = Contact.getContactPicture(this.context, lookupKey);
            if (bmp != null){
                Intent intent = new Intent(context, ContactsWidget.class);
                intent.setAction(ACTION_WIDGET_RECEIVER);
                intent.putExtra(ITENT_LOOKUPKEY, lookupKey);
                Tools.ToLog("LOOKUPKEY - IDENT=" + intent.getStringExtra(ITENT_LOOKUPKEY));

                RemoteViews itemView = new RemoteViews(this.context.getPackageName(), R.layout.widget_itemview);
                itemView.setImageViewBitmap(R.id.widget_ImageView, bmp);
                PendingIntent actionPendingIntent = PendingIntent.getBroadcast(this.context, 0, intent, 0);
                itemView.setOnClickPendingIntent(R.id.widget_ImageView, actionPendingIntent);
                rv.addView(R.id.widgetContainer, itemView);
            }
        }
        appWidgetManager.updateAppWidget(id, rv);
    }

I tested the Lookupkey and the lookupkey from the intent over the log and it works on this side (variable lookupKey == intent.getStringExtra(ITENT_LOOKUPKEY)). When I now receive the intent because I clicked on a contact picture the intent extra info is always the same. No matter which of the contact pictures I clicked. This is the receive code:

public void onReceive(Context context, Intent intent) {
    if (intent.getAction().equals(ACTION_WIDGET_RECEIVER)) {
        String lookupKey = intent.getStringExtra(ITENT_LOOKUPKEY);
        Toast.makeText(context, "Lookup Key: " + lookupKey, Toast.LENGTH_SHORT).show();
        //Contact.openContact(this.context, lookupKey);             
    }
    super.onReceive(context, intent);
}

It’s always the lookupKey from the first added contact. Do I have to clear the intent somehow before adding another contact in the first function or what is the problem?

  • 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-23T14:04:47+00:00Added an answer on May 23, 2026 at 2:04 pm

    You only have one PendingIntent.

    Quoting the documentation:

    If the creating application later re-retrieves the same kind of PendingIntent (same operation, same Intent action, data, categories, and components, and same flags), it will receive a PendingIntent representing the same token if that is still valid

    Since you have the same operation (getActivity()) and the same Intent routing pieces each time, there is only one PendingIntent.

    Rather than setting the action to be ACTION_WIDGET_RECEIVER, make it be unique for each that you are creating in your loops.

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

Sidebar

Related Questions

Here is the code I have written: super(Add contact); setLayout(new FlowLayout()); IPAddress = new
When you add a new contact, the first row contains the add photo button
I'm trying to create a new contact and add it to the AddressBook but
I have a String list: List<String> listString = new ArrayList<String>(); listString.add(faq); listString.add(general); listString.add(contact); I
i am using the following code to open android defaults add contact activity to
I am using the following code but still its not able to add contact
Can you please help me for sorting a list alphabetically My code emailList.add(contact.getUserName()); String[]
I have an entries controller that allows users to add contact information the website.
I want to program an Add-Window to my application, much like the Add Contact-window
In my App, I need to invoke the native add contact view. Is 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.