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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:05:41+00:00 2026-06-11T15:05:41+00:00

I am making a livewallpaper using Andengine Live wallpaper extension. The problem is that

  • 0

I am making a livewallpaper using Andengine Live wallpaper extension. The problem is that when i try to attach a sprite (a background image) in OnCreateScene method, I get a null pointer exception. Can someone help me with this?

Following is my code :-

@Override
public EngineOptions onCreateEngineOptions() {

    this.mCamera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT);
    EngineOptions engineOptions = new EngineOptions(false, ScreenOrientation.PORTRAIT_FIXED, new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), mCamera);
    return engineOptions;

}

@Override
public void onCreateResources(
        OnCreateResourcesCallback rsrCallback)
        throws Exception {

    BitmapTextureAtlasTextureRegionFactory.setAssetBasePath("gfx/"); 
    background = new BitmapTextureAtlas(this.getTextureManager(), 480, 320);
    backTR = BitmapTextureAtlasTextureRegionFactory.createFromAsset(background,this.getAssets(), "background_small.png", 0, 0);
    background.load();

    rsrCallback.onCreateResourcesFinished();
}

@Override
public void onCreateScene(OnCreateSceneCallback sceneCallback)
        throws Exception {
    // creating main scene
    mMainScene = new Scene();
    IBackground myBack = new  Background(0.0f, 0.0f, 0.0f);
    mMainScene.setBackground(myBack);

    final Sprite bkground = new Sprite(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT, backTR, getVertexBufferObjectManager());
    mMainScene.getLastChild().attachChild(bkground);

    sceneCallback.onCreateSceneFinished(mMainScene);  
}

on line mMainScene.getLastChild().attachChild(bkground), I get a null pointer. The stack trace is attached.

Stack Trace of Error

  • 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-06-11T15:05:42+00:00Added an answer on June 11, 2026 at 3:05 pm

    I found an alternative solution of adding a sprite background to the wallpaper.

    Use the SpriteBackground class :-

    mMainScene.setBackground(new SpriteBackground(new Sprite(0, 0, backTR, this.getVertexBufferObjectManager())));
    

    This resolves the null pointer that i was getting earlier.

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

Sidebar

Related Questions

I'm making a live wallpaper that switches images with various transitions. But I want
When it comes to making Android live wallpaper, what are the things that are
I'm using AndEngine to create a live wallpaper and SharedPreferences for the settings. Here
I'm making a live wallpaper app and I was just wondering if I can
Making websites that appear correctly in IE is a big problem. Is there any
I don't want to be using: onSharedPreferenceChanged Because my Live Wallpaper is reinitialized every
I'm making a Live Wallpaper for Android 2.3.3 and it used the Visualizer class.
I'm making a Live wallpaper for Android, and I want it scroll as user
I'm making a Live Wallpaper and attempting to add some user preferences. If I
I'm entirely new to Android development, and I'm interested in making a live wallpaper.

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.