First of all you need to add this permession to your manifest.xml
<uses-permission android:name="android.permission.SET_WALLPAPER" />
Then you can use this to set it using the wallpaperManager :
WallpaperManager wallpaperManager = WallpaperManager.getInstance(MyActivity.this);
Drawable drawable = getResources().getDrawable(R.drawable.wallpaper_img);
Bitmap bitmap = ((BitmapDrawable) drawable).getBitmap();
wallpaperManager.setBitmap(bitmap);
Or you can use this to set the wallpaper using intent