我正在尝试从资源中设置壁纸,每次我这样做时,活动都会崩溃。这是代码:
WallpaperManager myWallpaperManager = WallpaperManager.getInstance(getApplicationContext());
try {
myWallpaperManager.setResource(R.drawable.wallpaper_1);
} catch(IOException e) {
Toast.makeText(wallpaper.this, "Wallpaper error!", Toast.LENGTH_SHORT).show();
}
Toast 永远不会出现,日志只是读取
Process com.test.app (pid 1583) has died.
紧接着
WIN DEATH: Window{b47fab10 com.test.app/com.test.app.MainActivity paused=false}
我尝试了 jpg 和 png 图像,但似乎都没有。知道我应该看什么吗?