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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:50:54+00:00 2026-05-26T12:50:54+00:00

I have two classes, CustomerPreferences which extends PreferenceActivity implements OnSharedPreferenceChangeListener and CustomerActivity which extends

  • 0

I have two classes, CustomerPreferences which extends PreferenceActivity implements OnSharedPreferenceChangeListener and CustomerActivity which extends Activity. In CustomerActivity, I calculate some values. In CustomerPreferences there’s a particular ListPreference I want to monitor. When the user enters CustomerPreferences–which is done via a menu option on CustomerActivity–and changes that ListPreference, then hits the back button and returns to CustomerActivity, I want to recalculate my values based on the new preference setting. If the user goes into CustomerPreferences but doesn’t change the value of the ListPreference, I don’t want to recalculate anything upon return to CustomerActivity.

How can I do this?

I figure I’ll need to do something in CustomerPreferences.onSharedPreferenceChanged as well as maybe CustomerPreferences.onBackPressed, then probably handle something in CustomerActivity.

  • 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-26T12:50:54+00:00Added an answer on May 26, 2026 at 12:50 pm

    You can handle the change in CustomerActivity’s onResume() method. So after the user presses back, in onResume(), go through your preferences and recalculate your values and change your GUI representation based on the calculated values.

    Sure, sometimes this will be unnecessary as the user may not have changed anything. As long as your calculations aren’t too heavy this should not be cause for concern.

    Another thing you can do is set a boolean in shared preferences such as preferencesChanged which will get set to true in CustomerPreferences.onSharedPreferenceChanged. Then check preferencesChanged in onResume(). If true do your recalculations. Otherwise do nothing.

    Another option is to start the preferences activity for a result with startActivityForResult(). Then do the recalculations in onActivityResult() in CustomerActivity. The result value would be set in CustomerPreferences.onSharedPreferenceChanged

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

Sidebar

Related Questions

i have two classes which have some common methods like funcA(), funcB() and some
I have two classes X and Y, like this: class X implements Serializable {
I have two classes (A and B) which depend on each other in following
I have two classes, a server and some clients. The server class make a
I have two classes defined in different h files and each class has some
I have two classes(MyWidget,ViewContact). In MyWidget, there is a QLineEdit and QListWidget. The contents
I have two classes which is in different packages (folder). How can I call
I have two classes that extend the activity class. Each class has it's own
I have two classes: container which contains dynamic ordered list of Element . What
I have two classes with nested generics. Is there a way to get rid

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.