Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android

Wallpaper manager type raw error?

When trying to set a wallpaper I keep getting the error above ("expecting resource of type raw"). I was able to fill an imageView field with the image on the click of a button so I probably need to load in the image in a different way or use a different command to set the wallpaper. The code I'm using is the following:

WallpaperManager myWallpaperManager = WallpaperManager.getInstance(getApplicationContext());
try {
     myWallpaperManager.setResource(R.drawable.image5);
} catch (IOException e) {
     e.printStackTrace();
}

I have followed the basic android course here and read up on some other tutorials though I'm unable to figure out why this is happening. Does anyone have an idea about what I'm doing wrong or what I'm forgetting? Thanks in advance!!

What are you trying to achieve here? Are you trying to take the image in the ImageView and set it as the wallpaper for the device?