0

When selecting a wallpaper in android through the wallpaper selector, the os prompts the user to select from a list of wallpapers and to my knowledge some wallpaper applications, such as Wallpaper Engine, but when setting the wallpaper through code, it seems to be possible to only set a drawable image as a wallpaper. Is there any way to, for example, open this system prompt etc. and allow the user to select the wallpaper or wallpaper application?

Currently it seems it's possible to select images with this method and use them through this method.

I suppose it could be done somehow with the ACTION_LIVE_WALLPAPER_CHOOSER constant specified in android studio, but I wasn't able to find documentation on how to create a system selector prompt with that?

Just to clarify, the application itself is not supposed to be a wallpaper displayer, but rather it only sets the wallpaper drawable or another independent wallpaper drawer application.

Edit: The wallpaper/engine has to be chosen beforehand by the user, after which the app will automatically at some point in time apply it

Edit 2: I tested some methods posted previously on SO, but wasn't able to get them working on API 30, even when trying to copy paste the code directly as a last result. The code was taken from here and can be summarized as such:

PackageManager m_package_manager = getContext().getPackageManager();
        List<ResolveInfo> available_wallpapers_list =
                m_package_manager.queryIntentServices(
                        new Intent(WallpaperService.SERVICE_INTERFACE),
                        PackageManager.GET_META_DATA);
        return available_wallpapers_list;

The returned list is empty even if some additional live wallpaper applications have been installed

Nuubles
  • 165
  • 1
  • 13

1 Answers1

0

If you add this intent filter to your activity in the manifest, it should appear in the chooser:

    <activity
        android:name=".ChangeWallpaperActivity"
        android:exported="true">
        <intent-filter>
            <!-- This is the important part -->
            <action android:name="android.intent.action.SET_WALLPAPER" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </activity>

You can test this with the following bit of code:

    Intent intent = new Intent("android.intent.action.SET_WALLPAPER");
    try {
        startActivity(intent);
        } catch (ActivityNotFoundException e) {
        Log.w(TAG, "No activity found to handle " + intent.toString());
    }
HapaxLegomenon
  • 111
  • 1
  • 7
  • It seems that this way it's not possible to handle the setting of wallpaper programmatically. I've edited the question to be a bit more accurate. Thanks to this post I was able to find some posts that give a solution though: https://stackoverflow.com/questions/30618690/get-all-live-wallpapers-from-device https://stackoverflow.com/questions/12842924/how-do-i-move-to-live-wallpaper-preview-from-app I'll have to try these out once I get my usb ports working – Nuubles Mar 22 '22 at 17:00
  • I was able to test the methods given in those two posts mentioned and wasn't able to get either one of them working. I'll update the post with the testing results – Nuubles Mar 24 '22 at 10:53