Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to load resources or assets in GLWallpaper service

I am trying to develop an Android live wallpaper using OpenGL wallpaper service , I am able to create live wallpaper as in this example by Mark F Guerra But I want to add some sprite animation to my wallpaper.

I have already created a OpenGL ES sprite animation in another project. I just want to recreate my animation in the live wallpaper project.

But in my live wallpaper project i am not able to get Context and load my images from assets or resources

Any suggestions or sample codes or link about loading resourses or asset files while using glwallpaper service will be very helpfull.

All suggestions and/or sample codes are welcome.

like image 819
Renjith K N Avatar asked Nov 04 '22 13:11

Renjith K N


1 Answers

We can use the context as shown below..

in wallpaper service class: 
------------------- 
renderer = new GlRenderer(this); 

in renderer class: 
---------------- 
private Context context; 

public GlRenderer(Context context) { 
this.context = context; 

Instead of this we can use getAssets() or getResources() as parameter to renderer .
On using getAssets() you can get the files saved in assets folder and by using getResources() you can get the files placed inside the resources folder in your project.

like image 131
Lijo John Avatar answered Nov 14 '22 12:11

Lijo John