2016-08-06 37 views
2
public HeavyLifter(Context context, Handler callback) { 
     this.context = context; 
     this.callback = callback; 
     this.manager = (WallpaperManager) context.getSystemService(Context.WALLPAPER_SERVICE); 
    } 

Error: Suspicious cast to WallpaperManager for a WALLPAPER_SERVICE: expected WallpaperService [ServiceCast] this.manager = (WallpaperManager) context.getSystemService(Context.WALLPAPER_SERVICE);我在嘗試設置壁紙

我該如何解決這個問題,當出現以下錯誤?

回答

0

您應該使用WallpaperManagergetInstance()方法來查看實例。

更改如下:

this.manager = (WallpaperManager) context.getSystemService(Context.WALLPAPER_SERVICE); 

要這樣:

this.manager = WallpaperManager.getInstance(context); 
+0

謝謝。這有助於.. –