Any ideas?
On Oct 19, 12:44 pm, Rockline <rockl...@gmail.com> wrote: > Hi gents, > > I'm trying to develop an animatedwallpaperfor Android 2.1. > My first step would be to draw aJPEGimage onto the screen but it > doesn't seem to work. > > Any idea? > > public class RumblefishWallpaper extends WallpaperService { > > @Override > public void onCreate() { > super.onCreate(); > } > > @Override > public void onDestroy() { > super.onDestroy(); > } > > @Override > public Engine onCreateEngine() { > Context c = this.getApplicationContext(); > return new RumblefishWallpaperEngine(c); > } > > public class RumblefishWallpaperEngine extends Engine { > private float mTouchX = -1; > private float mTouchY = -1; > private Context myContext; > > RumblefishWallpaperEngine(Context c) > { > myContext = c; > drawFrame(); > } > > private final Runnable mDrawCube = new Runnable() { > public void run() { > drawFrame(); > } > }; > > @Override > public void onCreate(SurfaceHolder surfaceHolder) { > super.onCreate(surfaceHolder); > > // By default we don't get touch events, so enable them. > setTouchEventsEnabled(true); > } > > /* > * Store the position of the touch event so we can use it for > drawing later > */ > @Override > public void onTouchEvent(MotionEvent event) { > if (event.getAction() == MotionEvent.ACTION_MOVE) { > mTouchX = event.getX(); > mTouchY = event.getY(); > } else { > mTouchX = -1; > mTouchY = -1; > } > drawFrame(); > super.onTouchEvent(event); > } > > void drawFrame() { > final SurfaceHolder holder = getSurfaceHolder(); > > Canvas c = null; > try { > c = holder.lockCanvas(); > if (c != null) { > // draw something > Resources alpha = myContext.getResources(); > Drawable a = > alpha.getDrawable(R.drawable.icon); > a.draw(c); > } > } finally { > if (c != null) holder.unlockCanvasAndPost(c); > } > } > > } > > > > > > > > } -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en