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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:57:22+00:00 2026-05-26T14:57:22+00:00

Given two identical widgets with different data, A and B, when the data for

  • 0

Given two identical widgets with different data, A and B, when the data for widget A is shown in the activity launched by the widget, the back button is pressed and then widget B is pressed it all works fine. However, when the data for widget A is shown, the home button is pressed and then widget B is pressed, the data for widget A is still shown. From Android – When launch the same activity from widget with different extras, how to prevent the same instance show up after returned from HOME button? it suggests that my problem is that both PendingIntents (for widgets A and B) are the same and differ only in extras and are therefore cached. I.e. in the extras is the widget id which is the key I need to retrieve all the data for the widget-press action. One suggestion was to use different data, but I can’t seem to get this to work. Here is the code:

Intent intent = new Intent(context, WidgetActivity.class);
intent.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId);
intent.setData(Uri.withAppendedPath(Uri.parse("droidln://widget/id/"),
               String.valueOf(appWidgetId)));
PendingIntent pendingIntent = 
               PendingIntent.getActivity(context, appWidgetId, intent, 0);

Adding the setData to the intent produced no difference. Any ideas on how to fix my problem of cached pending intents? I’ve also tried:

intent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);

and

intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

and

intent.setAction("actionstring" + System.currentTimeMillis());

all to no effect.

  • 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-26T14:57:22+00:00Added an answer on May 26, 2026 at 2:57 pm

    Finally (!) found the answer I was looking for, and it was as simple as I hoped it would be. The PendingIntents were getting setup and passed around correctly. However, I wasn’t explicitly doing anything with the new intent. When the home button is pressed, the activity retains the original intent which launched it. All I needed to do was overwrite it with the new intent like this in my Activity:

    @Override
    protected void onNewIntent(Intent intent) {
        setIntent(intent);
        super.onNewIntent(intent);
    }
    

    Then, the rest of the lifecycle kicks in (including onResume() where much of the processing in my Activity takes place) using the new intent, instead of the original one.

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

Sidebar

Related Questions

Given two identical boost::variant instances a and b , the expression ( a ==
Given two interface references obtained from different sources. Is there a programmatic way to
Given two MS SQL databases which are known to have identical schemas, how should
I have two tables that have identical columns. One table houses imported data, the
Let's say I have two different classes, both represent 2D coordinate data in the
Given two integers a and b , how would I go about calculating the
Given two sets A and B, what is the common algorithm used to find
Given two 3D vectors A and B, I need to derive a rotation matrix
Given two colors and n steps, how can one calculate n colors including the
Given two date ranges, what is the simplest or most efficient way to determine

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.