我目前正在研究绘制到画布上的密集 LiveWallpaper。我偶然看到了以下视频:http ://www.youtube.com/watch?v=v9S5EO7CLjo 。
但是,当我尝试实现硬件加速时,出现错误。这是我的代码:
if (c != null && mStaticRects.length > 10 && c.isHardwareAccelerated())
drawSurfacePortrait(c);
if (c != null && mStaticRects.length < 20 && c.isHardwareAccelerated())
drawSurfaceLandscape(c);
当我运行它时,这是相应的错误:
AndroidRuntime(382): java.lang.NoSuchMethodError: android.graphics.Canvas.isHardwareAccelerated
最后这是我的清单......
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="stuff.of.mine"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="7" android:targetSdkVersion="15" />
<uses-permission android:name="android.permission.VIBRATE" ></uses-permission>
<uses-feature
android:name="android.software.live_wallpaper"
android:required="true" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
***android:hardwareAccelerated="true"***>
<service
android:name=".SomeWPService"
android:permission="android.permission.BIND_WALLPAPER"
***android:hardwareAccelerated="true"***>
<intent-filter>
<action android:name="android.service.wallpaper.WallpaperService" />
</intent-filter>
<meta-data
android:name="android.service.wallpaper"
android:resource="@xml/mylwp" />
</service>
</application>