Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: how to determine if a Live Wallpaper is set or not

I would like to know if my live wallpaper has been set or not, this is because I have a button "set wallpaper" that I would like to enable only if my wallpaper hasn't already been set.

Thaks to all

like image 663
Lorenzo Barbagli Avatar asked Dec 13 '25 23:12

Lorenzo Barbagli


1 Answers

Thanks to ImZaat's answer I found the solution, ImZaat's code is not working for me, as I would like to know if my wallpaper is running, but not from the wallpaper engine itself, from one other activity instead (it's an Activity used for setting some preferences about the wallpaper, so it's inside the same packege).

This is what I did and it's working fine (the code is inside the onCreate() method in the Activity:

    WallpaperManager wpm = WallpaperManager.getInstance(this);
    WallpaperInfo info = wpm.getWallpaperInfo();

    if (info != null && info.getPackageName().equals(this.getPackageName())) {
        Log.d(TAG, "We're already running");
    } else {
        Log.d(TAG, "We're not running");
    }
like image 72
Lorenzo Barbagli Avatar answered Dec 15 '25 13:12

Lorenzo Barbagli



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!