Example usage for android.app WallpaperManager getWallpaperInfo

List of usage examples for android.app WallpaperManager getWallpaperInfo

Introduction

In this page you can find the example usage for android.app WallpaperManager getWallpaperInfo.

Prototype

public WallpaperInfo getWallpaperInfo() 

Source Link

Document

If the current wallpaper is a live wallpaper component, return the information about that wallpaper.

Usage

From source file:arun.com.chameleonskinforkwlp.MainActivity.java

/**
 * Prompt the user to set our app as live wallpaper if the user has not set it.
 *///  w w w .jav a2  s . com
private void initSetWallpaperPrompt() {
    final WallpaperManager wm = WallpaperManager.getInstance(getApplicationContext());
    if ((wm.getWallpaperInfo() != null
            && wm.getWallpaperInfo().getPackageName().equalsIgnoreCase(getPackageName()))) {
        // We are good
    } else {
        // Ask user.
        Snackbar.make(binding.coordinatorLayout, R.string.set_live_wallpaper_promt, Snackbar.LENGTH_INDEFINITE)
                .setAction(android.R.string.ok, new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        launchSetWallpaperScreen();
                    }
                }).show();
    }
}