我正在制作一个简单的Android动态壁纸,我正在按照Hello,Android的第12章作为我的指南。墙纸服务的基本结构如下所示:publicclassMyWallpaperextendsWallpaperService{privateclassMyEngineextendsEngine{//...}//...}根据书MyEngine必须是MyWallpaper的内部类。我没有理由对此提出异议,但这本书没有解释为什么必须如此。我不想纯粹出于风格/美学原因而使用内部类。我想知道MyEngine是否真的必须是私有(private)内部类,如果是,为什么? 最佳
我有一个显示图像的动态壁纸。我在Activity中更改了该图像。然后我需要通知动态壁纸,以便它知道重新加载资源。Intent似乎是完美、简单的解决方案:Intentintent=newIntent(MyActivity.this,MyWallpaperService.class);startService(intent);我和MyWallpaperService@OverridepublicintonStartCommand(Intentintent,intflags,intstartId){...}我还需要知道,在另一个服务中,用户何时点击屏幕。我使用完全相同的发送和接收Intent
我正在为Android开发动态壁纸。代码有效,但我遇到了性能问题。基本上我正在绘制位图并移动它们。有15张小图像,效果很好。但是有了50张更大的图像,它就开始滞后了。在我的移动对象中,我在构造函数中创建位图并像这样显示它:publicvoiddrawFrame(Canvascanvas){Positionp=movingStrategy.move();Matrixmatrix=newMatrix();matrix.postScale(scale,scale);matrix.postRotate(p.getRotation());matrix.postTranslate(p.getPos