Android Permission Denial starting Intent for Wall

2019-08-12 02:03发布

问题:

Unfortunately when I try to run my wallpaper I get an error message saying Permission Denial starting Intent and requires android.permission.BIND_WALLPAPER but I can't seem to figure out why. My manifest looks like the following:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.package">

    <uses-feature android:name="android.software.live_wallpaper" />
    <uses-permission android:name="android.permission.SET_WALLPAPER" />

    <application
        android:exported="true"
        android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:permission="android.permission.BIND_WALLPAPER">

        <service
            android:name="WallpaperService"
            android:icon="@drawable/icon"
            android:label="@string/app_name"
            android:permission="android.permission.BIND_WALLPAPER">

            <intent-filter>
                <action android:name="android.service.wallpaper.WallpaperService" />
            </intent-filter>
            <meta-data
                android:name="android.service.wallpaper"
                android:resource="@xml/livewallpaper" />

        </service>
        <activity
            android:name=".WallpaperSetClass"
            android:exported="true"
            android:permission="android.permission.BIND_WALLPAPER"
            android:label="@string/app_name">

            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>
</manifest>

The live wallpaper does run perfectly if I set it through the live wallpaper part of my phone, but I would like to have a settings area as well to be able to open in which I can't. At the moment my settings class is basically empty containing just an onCreate function and a layout with a button.

Is there something I'm missing? I seem to have the permissions along with android:exported

回答1:

Turns out I had

android:permission="android.permission.BIND_WALLPAPER"

In the wrong spot, it should be in the service tag, and only have ONE, having multiple will break it.