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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T07:40:56+00:00 2026-05-27T07:40:56+00:00

I’m using AndEngine to create a Live Wallpaper and I have everything set up

  • 0

I’m using AndEngine to create a Live Wallpaper and I have everything set up the right way for the Settings menu to come up. I’m just not sure how to actually switch out the current images that load by default with images that users can choose in the Settings menu.

Example:
By default, the program loads the background image2 and the top layer image 1.
If a user chooses to use background image 3 via the Settings menu, I would like image3 to replace image2.

Here is my main code:

public class PhysicsWallpaperActivity extends BaseLiveWallpaperService implements SharedPreferences.OnSharedPreferenceChangeListener {
    // ===========================================================
    // Constants
    // ===========================================================


    public static final String SHARED_PREFS_NAME = "preferences";
    private static final int CAMERA_WIDTH = 720;
    private static final int CAMERA_HEIGHT = 480;

    // ===========================================================
    // Fields
    // ===========================================================

    private Camera mCamera;


    private BitmapTextureAtlas mAutoParallaxBackgroundTexture;

    private TextureRegion mParallaxLayerBack;
    private TextureRegion mParallaxLayerFront;

    private SharedPreferences prefs;




    @Override
    public org.anddev.andengine.engine.Engine onLoadEngine() {
            this.mCamera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
            return new org.anddev.andengine.engine.Engine(new EngineOptions(true, ScreenOrientation.PORTRAIT, new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), this.mCamera));
    }

    @Override
    public void onLoadResources() {
        prefs = PhysicsWallpaperActivity.this.getSharedPreferences(SHARED_PREFS_NAME, 0);
        prefs.registerOnSharedPreferenceChangeListener(this);


            BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/");


            this.mAutoParallaxBackgroundTexture = new BitmapTextureAtlas(2048, 2048, TextureOptions.DEFAULT);
            this.mParallaxLayerFront = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.mAutoParallaxBackgroundTexture, this, "image1.png", 0, 800);
            this.mParallaxLayerBack = BitmapTextureAtlasTextureRegionFactory.createFromAsset(this.mAutoParallaxBackgroundTexture, this, "image2.jpg", 0, 0);

            this.mEngine.getTextureManager().loadTextures(this.mAutoParallaxBackgroundTexture);
    }

    @Override
    public Scene onLoadScene() {
            this.mEngine.registerUpdateHandler(new FPSLogger());

            final Scene scene = new Scene();
            final AutoParallaxBackground autoParallaxBackground = new AutoParallaxBackground(0, 0, 0, 5);
            autoParallaxBackground.attachParallaxEntity(new ParallaxEntity(-10.0f, new Sprite(0, CAMERA_HEIGHT - this.mParallaxLayerBack.getHeight(), this.mParallaxLayerBack)));
            autoParallaxBackground.attachParallaxEntity(new ParallaxEntity(0.0f, new Sprite(0, CAMERA_HEIGHT - this.mParallaxLayerFront.getHeight(), this.mParallaxLayerFront)));
            scene.setBackground(autoParallaxBackground);

            return scene;
    }

....
....

    @Override
    public void onSharedPreferenceChanged(SharedPreferences pSharedPrefs, String pKey)
    {

    }


}    

I’m not sure what has to be added after:

prefs = PhysicsWallpaperActivity.this.getSharedPreferences(SHARED_PREFS_NAME, 0);
        prefs.registerOnSharedPreferenceChangeListener(this);

Here is my preference.xml file which has the actual Settings menu:

<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
        <PreferenceCategory
                android:title="Main Settings">
                 <ListPreference
           android:title="List Preference"
           android:summary="This preference allows to select an item in an array"
           android:key="listPref"
           android:defaultValue="1"
           android:entries="@array/background"
           android:entryValues="@array/background_values" /> 
        </PreferenceCategory>
</PreferenceScreen>

I guess my main question is how do I go about loading the new image the user has chosen and then applying it to the actual wallpaper?

  • 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-27T07:40:56+00:00Added an answer on May 27, 2026 at 7:40 am

    Found the soulution:

    Created this:

        @Override
        public void onSharedPreferenceChanged(SharedPreferences pSharedPrefs, String pKey)
        {           
                settingsChanged = true;
        }
    

    Added:

        @Override
        public void onResume(){
            super.onResume();
            if(settingsChanged)
            {
                    BuildScene();
                    settingsChanged = false;
            }
        }
    

    (BuildScene()) is a call inside my onLoadScene() method.)

    Then I just custom coded If, Else statements inside the BuildScene() method to figure out which option the user is currently using, and then applied the new image.

    • 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
this is what i have right now Drawing an RSS feed into the php,
I have thousands of HTML files to process using Groovy/Java and I need to
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
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
Basically, what I'm trying to create is a page of div tags, each has
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I have a French site that I want to parse, but am running into

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.