Androidの壁紙を変更するサービスを利用しています。画像のパスをサービスに渡し、次のコードを使用して画像を壁紙として設定しています。
@Override
public void run() {
try {
final String imagePath[] = mSelectedImgPath.split(",");
while (true) {
for (int i = 0; i < imagePath.length; i++) {
bitmap = BitmapFactory.decodeFile(imagePath[i]);
this.setWallpaper(bitmap);
Thread.sleep(1000 * time);
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
次のエラーが表示されます:
01-25 15:59:12.410: E/AndroidRuntime(1702): FATAL EXCEPTION: Thread-149
01-25 15:59:12.410: E/AndroidRuntime(1702): java.lang.OutOfMemoryError
01-25 15:59:12.410: E/AndroidRuntime(1702): at android.graphics.BitmapFactory.nativeDecodeStream(Native Method)
01-25 15:59:12.410: E/AndroidRuntime(1702): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:493)
01-25 15:59:12.410: E/AndroidRuntime(1702): at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:299)
01-25 15:59:12.410: E/AndroidRuntime(1702): at android.graphics.BitmapFactory.decodeFile(BitmapFactory.java:324)
01-25 15:59:12.410: E/AndroidRuntime(1702): at com.wallpaper.demo.WallpaperChangeService.run(WallpaperChangeService.java:55)
01-25 15:59:12.410: E/AndroidRuntime(1702): at java.lang.Thread.run(Thread.java:856)
ありがとう