Search code examples
androidservicewallpaper

Can't apply live wallpaper


java.lang.SecurityException: Selected service does not require android.permission.BIND_WALLPAPER

So this does work:

<application android:icon="@drawable/icon"
    android:label="Wallpaper"
    android:permission="android.permission.BIND_WALLPAPER">

However, your app is essentially JUST a wallpaper in this scenario. My app is fully fledged with a wallpaper bundled in it. If I use the above, it will not let me run the app itself. Just set a wallpaper.

So I tried:

<uses-permission android:name="android.permission.BIND_WALLPAPER" />

Which gives the error shown. I can see the preview running fine, but as soon as I hit apply, or settings. BOOM HEADSHOT!

Oh and of course, Ive tried it without permissions set with the same error

How Do I still run the app, plus allow use of bundled wallpaper.


Solution

  • According to Android maninfest.permissions doc

    String: BIND_WALLPAPER: Must be required by a WallpaperService, to ensure that only the system can bind to it.

    So infact, if you add the permission to your service. It works fine. It is a security exception to make sure the system can only bind to it.

        <service android:name=".LiveWallpaper"
            android:label="Wallpaper"
            android:icon="@drawable/ic_launcher"
            android:permission="android.permission.BIND_WALLPAPER">