This tutorial tells you how to Setup and Create Live Wallpaper in Android Studio using AndEngine
Prerequisite
Step 1: Start Android Studio and create new project. Fill project details and click 'Next'.
Step 2: Click 'Next'.
Step 3: Click 'Next'.
Step 4: Click 'Finish'.
Step 5: Now change project structure view(optional).
Step 6: Right click on root project and add a directory..
Step 7: Enter name for new directory(in my case its 'other_lib') and click 'OK'.
Step 8: New directory is created. Now just copy and paste downloaded AndEngine and AndEngine Live Wallpaper Extension in this directory.
Step 9: Right click on 'AndEngine' and create a new file. Enter name 'build.gradle' in the text box and click 'OK'.
apply plugin: 'com.android.library' android { compileSdkVersion 17 buildToolsVersion "19.1" defaultConfig { minSdkVersion 14 targetSdkVersion 19 } compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } sourceSets { main { manifest.srcFile 'AndroidManifest.xml' java.srcDirs = ['src'] resources.srcDirs = ['src'] res.srcDirs = ['res'] assets.srcDirs = ['assets'] } instrumentTest.setRoot('HelloToLivewallpaper') } } |
Step 11: Now open 'AndroidManifest.xml' file which is located in 'AndEngine' and add "application closing tag".<application/>

apply plugin: 'com.android.library' android { compileSdkVersion 17 buildToolsVersion "19.1" defaultConfig { minSdkVersion 14 targetSdkVersion 19 } compileOptions { sourceCompatibility JavaVersion.VERSION_1_7 targetCompatibility JavaVersion.VERSION_1_7 } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } sourceSets { main { manifest.srcFile 'AndroidManifest.xml' java.srcDirs = ['src'] resources.srcDirs = ['src'] res.srcDirs = ['res'] assets.srcDirs = ['assets'] } instrumentTest.setRoot('HelloToLivewallpaper') } } dependencies { compile project(':other_lib:AndEngine-GLES2-AnchorCenter') } |
Step 13: Now open 'AndroidManifest.xml' file which is located in 'AndEngine Live Wallpaper Extension' and add "application closing tag".<application/>
Step 14: Now create new directory 'xml' in app>src>main>res>
1 2 3 4 5 6 | <?xml version="1.0" encoding="utf-8"?> <wallpaper xmlns:android="http://schemas.android.com/apk/res/android" android:thumbnail="@mipmap/ic_launcher" android:description="@string/wallpaper_description" /> |
Step 15: Now create new resource file 'wallpaper' in 'xml' directory and add this code in it.
Step 16: Create respective string resource(Name of our live wallpaper).
include ':app' include ':other_lib:AndEngine-GLES2-AnchorCenter' include ':other_lib:AndEngineLiveWallpaperExtension-GLES2-AnchorCenter' |
Step 17: Now open root project's 'settings.gradle' file and add this code in it.
compile fileTree(dir: 'libs', include: ['*.jar']) compile project(':other_lib:AndEngine-GLES2-AnchorCenter') compile project(':other_lib:AndEngineLiveWallpaperExtension-GLES2-AnchorCenter')
Step 18: Now open app's 'build.gradle' file and add this code in it.
Step 19: Clean project.
package com.example.hellotolivewallpaper; import android.util.DisplayMetrics; import android.util.Log; import android.view.WindowManager; import org.andengine.engine.camera.Camera; import org.andengine.engine.options.EngineOptions; import org.andengine.engine.options.ScreenOrientation; import org.andengine.engine.options.resolutionpolicy.RatioResolutionPolicy; import org.andengine.entity.scene.IOnSceneTouchListener; import org.andengine.entity.scene.Scene; import org.andengine.entity.scene.background.Background; import org.andengine.entity.sprite.AnimatedSprite; import org.andengine.extension.ui.livewallpaper.BaseLiveWallpaperService; import org.andengine.input.touch.TouchEvent; import org.andengine.opengl.texture.TextureOptions; import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlas; import org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory; import org.andengine.opengl.texture.region.ITiledTextureRegion; import java.io.IOException; public class HelloToLiveWallpaperService extends BaseLiveWallpaperService implements IOnSceneTouchListener { private static final String TAG = "HelloTo"; private static float CAMERA_WIDTH = 480; private static float CAMERA_HEIGHT = 800; private Scene mScene; private ITiledTextureRegion mHelloTR; private AnimatedSprite mHelloSprite; @Override public EngineOptions onCreateEngineOptions() { try { final DisplayMetrics displayMetrics = new DisplayMetrics(); WindowManager wm = (WindowManager) getSystemService(WINDOW_SERVICE); wm.getDefaultDisplay().getMetrics(displayMetrics); wm.getDefaultDisplay().getRotation(); CAMERA_WIDTH = displayMetrics.widthPixels; CAMERA_HEIGHT = displayMetrics.heightPixels; } catch (Exception e) { Log.e(TAG, "onCreateEngineOptions " + e.toString()); } //create a camera Camera mCamera = new Camera(0, 0, CAMERA_WIDTH, CAMERA_HEIGHT); //engine options return new EngineOptions(true, ScreenOrientation.PORTRAIT_FIXED, new RatioResolutionPolicy(CAMERA_WIDTH, CAMERA_HEIGHT), mCamera); } @Override public void onCreateResources(OnCreateResourcesCallback pOnCreateResourcesCallback) throws IOException { //create texture BitmapTextureAtlas textureAtlas = new BitmapTextureAtlas(getTextureManager(), 600, 150, TextureOptions.BILINEAR); this.mHelloTR = BitmapTextureAtlasTextureRegionFactory.createTiledFromAsset(textureAtlas, getAssets(), "gfx/text_hello.png", 0, 0, 2, 1); this.getEngine().getTextureManager().loadTexture(textureAtlas); pOnCreateResourcesCallback.onCreateResourcesFinished(); } @Override public void onCreateScene(OnCreateSceneCallback pOnCreateSceneCallback) throws IOException { //create a scene mScene = new Scene(); //create a black background mScene.setBackground(new Background(0.0f, 0.0f, 0.0f)); //create a sprite mHelloSprite = new AnimatedSprite(0.5f * CAMERA_WIDTH, 0.5f * CAMERA_HEIGHT, mHelloTR, this.getVertexBufferObjectManager()); //attach our sprite to the scene mScene.attachChild(mHelloSprite); //register scene touch listener mScene.setOnSceneTouchListener(this); pOnCreateSceneCallback.onCreateSceneFinished(mScene); } @Override public void onPopulateScene(Scene pScene, OnPopulateSceneCallback pOnPopulateSceneCallback) throws IOException { pOnPopulateSceneCallback.onPopulateSceneFinished(); } @Override public boolean onSceneTouchEvent(Scene pScene, TouchEvent pSceneTouchEvent) { //handling scene on touch event if (pScene == mScene) { switch (mHelloSprite.getCurrentTileIndex()) { case 0: mHelloSprite.setCurrentTileIndex(1); break; case 1: mHelloSprite.setCurrentTileIndex(0); break; } } return false; } }
Step 20: Create new java file 'HelloToLiveWallpaperService.java' and just paste this code.
Step 21: Create new directory 'assets' in app>main>
Step 22: Create new directory 'gfx' in app>main>assets>
(Download)
Step 23: Add this 'text_hello.png' image in app>main>assets>gfx>
<!-- Live Wallpaper Service --> <service android:name=".HelloToLiveWallpaperService" android:description="@string/wallpaper_description" android:enabled="true" android:icon="@mipmap/ic_launcher" android:permission="android.permission.BIND_WALLPAPER" > <intent-filter> <action android:name="android.service.wallpaper.WallpaperService" /> </intent-filter> <meta-data android:name="android.service.wallpaper" android:resource="@xml/wallpaper" /> </service>
Step 24: Open 'AndroidManifest.xml' and this code before 'application ending tag'.
package com.example.hellotolivewallpaper; import android.app.WallpaperManager; import android.content.ComponentName; import android.content.Intent; import android.os.Bundle; import android.support.v7.app.AppCompatActivity; import android.widget.Toast; public class MainActivity extends AppCompatActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Intent intent; // try the new Jelly Bean direct android wallpaper chooser first try { ComponentName component = new ComponentName(getPackageName(), getPackageName() + ".HelloToLiveWallpaperService"); intent = new Intent(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER); intent.putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT, component); startActivity(intent); } catch (android.content.ActivityNotFoundException e3) { // try the generic android wallpaper chooser next try { intent = new Intent(WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER); startActivity(intent); } catch (android.content.ActivityNotFoundException e2) { // that failed, let's try the nook intent try { intent = new Intent(); intent.setAction("com.bn.nook.CHANGE_WALLPAPER"); startActivity(intent); } catch (android.content.ActivityNotFoundException e) { // everything failed, let's notify the user Toast.makeText(MainActivity.this, "Wallpaper chooser not found", Toast.LENGTH_SHORT).show(); } } } finish(); } }Step 25: Finally open app>main>java>com>example>hellotolivewallpaper>MainActivity.java and paste this code in it. That's it.
Run the app...
Output:
Full source code(rar formate) - Download
HAPPY CODING...
Search Tags: how to make live wallpaper in android studio live wallpaper for android apk create live wallpaper for android studio android live wallpaper android studio how to create live wallpaper for android using android studio Create a Live Wallpaper on Android Studio How to create a Live Wallpaper in Android how to make live wallpaper for android phones how to make a live wallpaper for android tutorial Create Your Own Android Live Wallpaper using AndEngine How to create a live wallpaper app in Android Studio How to Use OpenGL ES 2 in an Android Live Wallpaper
Lets celebrate this Ganesh Chathurthi by praying to god Ganesha by installing his beautiful 3D Ganesh Live Wallpaper app.
ReplyDeletemany thanks, this is very usefull!
ReplyDeleteEvery app development project is unique, and so are its costs. Sunrise Technologies' App Development Cost Calculator provides a customized cost estimate based on your app's specific requirements. Estimate Your Mobile App Development Costs with Sunrise Technologies
ReplyDeletetop AI companies USA
ReplyDeleteLooking for the top AI companies in the USA to elevate your business with intelligent solutions? This curated guide from Sunrise Technologies showcases the leading AI development firms transforming industries through innovation, automation, and smart data analytics. Whether you're a startup or an enterprise, these companies offer cutting-edge services in machine learning, natural language processing, predictive analytics, and more. Explore how these AI experts are driving business efficiency, customer engagement, and competitive growth across sectors. If you're planning to integrate AI into your digital roadmap, this list is the perfect starting point to discover the most trusted and impactful AI solution providers in the U.S.
Support local tech talent while getting world-class mobile solutions. As an Australian-owned firm, we understand the unique needs of domestic businesses better than offshore providers.
DeleteExplore more at Mobile app development company in australia
Working with app developers in Perth has been a game-changer. They bring professionalism, creativity, and technical expertise to every project. Highly recommend for digital transformation.
ReplyDeleteBest App Developers Perth
top AI companies Australia
ReplyDeleteExplore the top AI companies in Australia known for delivering cutting-edge artificial intelligence solutions across industries. This list features leading AI development firms specializing in machine learning, automation, and data-driven innovations.
ChatGPT app development cost
ReplyDeleteDiscover the real ChatGPT app development cost in this in-depth guide that outlines the essential components involved in building a high-functioning AI chatbot. From NLP integration and cloud infrastructure to UI/UX and post-launch support, understand how these factors influence overall AI chatbot app pricing.
Comparing in-house vs. outsourced development costs for 2025? This guide has the answers. A game-changer!Explore the A Complete Guide to the Software Development Cost 2025</a
ReplyDelete