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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T11:50:39+00:00 2026-05-30T11:50:39+00:00

I’ve just released my first live wallpaper for android. I bug tested it on

  • 0

I’ve just released my first live wallpaper for android. I bug tested it on my phone and several friends phones without finding any problems, but apparently on some devices it’s getting stuck in a recursive loop and causing a stack overflow error when the user tries to change settings.

I believe the problem is occurring because I have certain “theme” settings which need to change several other persisted values. For example one theme will set a default color, speed, background, etc. It seems that when I persist these values programmatically with Editor.commit(), it’s calling onSharedPreferenceChanged again, and again, and again…

Since this is a live wallpaper, I have a preview running behind the transparent preference screen, and I need it to reflect the settings changes as they’re made. I also need the sliders/color pickers/list preferences to reflect changes made both by the user directly, and programmatically when a “theme” is selected. The easiest way to do this seemed to be to change them with a preference editor in onSharedPreferenceChanged, and indeed, this works on many devices.

What can I do to make it work on all devices?

Here’s the relevant code:

public void onSharedPreferenceChanged(SharedPreferences prefs, String key) 
{


    if(key != null)
    {

    SharedPreferences.Editor editor = prefs.edit();

     hue = prefs.getInt("color", 0);
     BG_COLOR = prefs.getInt("background_color", 0);

//etc...



   if(key.matches("plasma_set"))
   {

       plasmaAtlasName = atlasName;
       editor.putString("atlasName", atlasName);

       //load each bolt set with defalut values

       if(plasmaAtlasName.equals("plasmaAtlas11"))
       {
           hue = 180;
           editor.putInt("speed", 10);
           editor.putInt("bolt_density", 2);
           BG_COLOR = 0;
           editor.putInt("background_color", BG_COLOR);
           editor.putInt("color", hue);
       }

       if(plasmaAtlasName.equals("plasmaAtlas9"))
       {
           hue = 330;
           editor.putInt("speed", 10);
           editor.putInt("bolt_density", 2);
           BG_COLOR = 0;
           editor.putInt("background_color", BG_COLOR);
           editor.putInt("color", hue);

       }

   //etc...
}

editor.commit();
}
}
  • 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-30T11:50:41+00:00Added an answer on May 30, 2026 at 11:50 am

    Ok, I figured it out. It was a simple matter of unregistering the listener before calling Editor.commit() and then registering it again afterward.

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I'm making a simple page using Google Maps API 3. My first. One marker
For some reason, after submitting a string like this Jack’s Spindle from a text
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I want to count how many characters a certain string has in PHP, but

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.