I wrote an app to do it, so that it can be done by ADB with no need to touch the device:
adb install the-app.apk
adb shell am broadcast -a com.blundell.app.SET_WALLPAPER -n com.blundell.app/.SetWallpaper
adb uninstall com.blundell.app
The app:
Manifest:
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.blundell.app"
>
<uses-permission android:name="android.permission.SET_WALLPAPER"/>
<application
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
tools:ignore="GoogleAppIndexingWarning"
>
<receiver
android:name=".SetWallpaper"
tools:ignore="ExportedReceiver"
>
<intent-filter>
<action android:name="com.blundell.app.SET_WALLPAPER"/>
</intent-filter>
</receiver>
</application>
</manifest>
No Activities.
Broadcast Receiver:
class SetWallpaper : BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) {
WallpaperManager.getInstance(context).setResource(R.raw.wallpaper)
}
}
That's it!
And the wallpaper itself lives in the /res/raw/ directory.
You could also pass the wallpaper location through the broadcast intent if you wanted.