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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:48:58+00:00 2026-05-26T13:48:58+00:00

I have 2 android intent objects that can be persisted as URLs and then

  • 0

I have 2 android intent objects that can be persisted as URLs and then rehydrated back into intent objects. I’m wondering what is the most effective way to compare any 2 intent objects to ensure that they end up resolving to the same activity with the same parameters etc. Using intent.filterEquals does this, but it does not include the extras.

Currently my code for the equals method looks like this:

            Intent a = Intent.parseUri(this.intentUrl,
                    Intent.URI_INTENT_SCHEME);

            Intent b = Intent.parseUri(other.intentUrl,
                    Intent.URI_INTENT_SCHEME);
            if (a.filterEquals(b)) {
                if (a.getExtras() != null && b.getExtras() != null) {
                    for (String key : a.getExtras().keySet()) {
                        if (!b.getExtras().containsKey(key)) {
                            return false;
                        } else if (!a.getExtras().get(key)
                                .equals(b.getExtras().get(key))) {
                            return false;

                        }
                    }
                }
                // all of the extras are the same so return true
                return true;
            } else { return false; }

But is there a better/cleaner way?

  • 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-26T13:48:59+00:00Added an answer on May 26, 2026 at 1:48 pm

    That’s probably as good as it gets, at least conceptually. However, I don’t think your algorithm covers cases where b has a key that a does not.

    I’d get both keySet() values and run an equals() on those, to confirm they both have the same keys. Then, iterate over one and run equals() on the value pair.

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

Sidebar

Related Questions

I have android.permission.READ_OWNER_DATA but I can't find any reliable code that would explain how
I have an Android project that branched into three different applications, app-1 , app-2
If I needed to build an android SDK that other developers can integrate into
I have a intent receiver in my android manifest, but would like to give
I have Android pet-project DroidIn which utilizes HttpClient 4 (built into Android) to do
I have an Android activity that displays a list of log entries (using a
recently I been trying to create an android app that uses JSON Objects to
I have a simple Android application that uses an instance of a class, let's
I'm back at trying out some Android dev again. I have an old HTC
I want install Android version 1.6 SDK. I already have Android development setup with

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.