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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T23:24:02+00:00 2026-05-21T23:24:02+00:00

I’m using PreferenceActivity to set some preferences about another BroadcastReciever that i have. While

  • 0

I’m using PreferenceActivity to set some preferences about another BroadcastReciever that i have.

While making the skeleton of the preferences GUI is really simple with XML file, i cant find my hands and legs around how to actually DO something with those preferences. especially:

  1. How do i register my BroadcastReciever to listen to changes in my preferences?
    Its look like that the context of the broadcast reciever is not the same as the activity so i’m not registering to the right SharedPreferences because i dont intercept those changes.

  2. How do i act in my PreferenceActivity upon changes in the preferences? i guess i dont need to register PreferenceActivity as listener to the preferences, so there must be more simple way.

  3. How do i change the UI of the PreferenceActivity appropriate to the changes in the preferences? for example, set the “Summary” attribute of a preference to the value that the user chose?

  4. How do i enable or disable some preferences that depends on another preference (like CheckBoxPreference)? so the user could edit those preferences only if he enabled the feature first.

I looked al over the documentation but there is no example of using PreferenceActivity beyond the point of just adding preferences from XML.

I feel like i’m missing something huge here, because it looks so simple, and yet i can’t figure it out…

Please try to answer on any of my question.

BTW:
I’m developing for Android 1.6 so all the new PreferenceFragment can’t be used.

  • 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-21T23:24:03+00:00Added an answer on May 21, 2026 at 11:24 pm

    How do i register my BroadcastReciever to listen to changes in my preferences?

    If the BroadcastReceiver is registered in the manifest, you don’t listen to changes in your preferences, because the BroadcastReceiver will only be around for milliseconds. Just read the latest values in during onReceive().

    If the BroadcastReceiver is registered by some other component calling registerReceiver(), that component can register an OnSharedPreferenceChangeListener with the SharedPreferences retrieved via PreferenceManager and getDefaultSharedPreferences().

    Its look like that the context of the broadcast reciever is not the same as the activity so i’m not registering to the right SharedPreferences because i dont intercept those changes.

    That sentence makes no sense.

    How do i act in my PreferenceActivity upon changes in the preferences?

    Register an OnSharedPreferenceChangeListener with the SharedPreferences retrieved via PreferenceManager and getDefaultSharedPreferences().

    How do i change the UI of the PreferenceActivity appropriate to the changes in the preferences?

    Generally, you don’t. You are welcome to register an OnSharedPreferenceChangeListener with the SharedPreferences retrieved via PreferenceManager and getDefaultSharedPreferences(). From there, you can get the Preference from your PreferenceActivity via findPreference() and adjust to suit.

    How do i enable or disable some preferences that depends on another preference (like CheckBoxPreference)? so the user could edit those preferences only if he enabled the feature first.

    Add android:dependency to your preference XML as needed.

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

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I'm making a simple page using Google Maps API 3. My first. One marker
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have some data like this: 1 2 3 4 5 9 2 6
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
We're building an app, our first using Rails 3, and we're having to build
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I am trying to loop through a bunch of documents I have to put

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.