Example usage for android.app WallpaperManager ACTION_CHANGE_LIVE_WALLPAPER

List of usage examples for android.app WallpaperManager ACTION_CHANGE_LIVE_WALLPAPER

Introduction

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

Prototype

String ACTION_CHANGE_LIVE_WALLPAPER

To view the source code for android.app WallpaperManager ACTION_CHANGE_LIVE_WALLPAPER.

Click Source Link

Document

Directly launch live wallpaper preview, allowing the user to immediately confirm to switch to a specific live wallpaper.

Usage

From source file:com.google.android.apps.muzei.IntroFragment.java

@Override
public void onViewCreated(final View view, @Nullable final Bundle savedInstanceState) {
    mActivateButton = view.findViewById(R.id.activate_muzei_button);
    mActivateButton.setOnClickListener(new View.OnClickListener() {
        @Override/*from   ww w.j  a va  2 s .  co m*/
        public void onClick(View view) {
            FirebaseAnalytics.getInstance(getContext()).logEvent("activate", null);
            try {
                startActivity(new Intent(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER)
                        .putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT,
                                new ComponentName(getContext(), MuzeiWallpaperService.class))
                        .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
            } catch (ActivityNotFoundException e) {
                try {
                    startActivity(new Intent(WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER)
                            .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
                } catch (ActivityNotFoundException e2) {
                    Toast.makeText(getContext(), R.string.error_wallpaper_chooser, Toast.LENGTH_LONG).show();
                }
            }
        }
    });
}

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

private void launchSetWallpaperScreen() {
    final Intent setWallpaper = new Intent();
    setWallpaper.setAction(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER);
    setWallpaper.putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT,
            new ComponentName(getPackageName(), ChameleonWallpaperService.class.getName()));
    startActivityForResult(setWallpaper, 0);
}

From source file:com.stanleyidesis.quotograph.ui.activity.LWQActivateActivity.java

@OnClick(R.id.button_lwq_activate)
void activate() {
    try {// w  w w . j  a  va 2s  . c  o m
        startActivity(new Intent(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER)
                .putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT,
                        new ComponentName(LWQActivateActivity.this, LWQWallpaperService.class))
                .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
        Toast.makeText(LWQActivateActivity.this, getString(R.string.toast_tap_set_wallpaper), Toast.LENGTH_LONG)
                .show();
    } catch (ActivityNotFoundException e) {
        try {
            startActivity(new Intent(WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER)
                    .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
            Toast.makeText(LWQActivateActivity.this, getString(R.string.toast_tap_set_wallpaper),
                    Toast.LENGTH_LONG).show();
        } catch (ActivityNotFoundException e2) {
            Toast.makeText(LWQActivateActivity.this, R.string.error_wallpaper_chooser, Toast.LENGTH_LONG)
                    .show();
        }
    }
    // Log tutorial as completed
    AnalyticsUtils.trackTutorial(false);
}

From source file:com.google.android.apps.muzei.MuzeiActivity.java

private void setupIntroModeUi() {
    mIntroContainerView = (ViewGroup) findViewById(R.id.intro_container);

    findViewById(R.id.activate_muzei_button).setOnClickListener(new View.OnClickListener() {
        @Override/*from  w  w w .  j a  va 2  s . c  om*/
        public void onClick(View view) {
            try {
                startActivity(new Intent(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER)
                        .putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT,
                                new ComponentName(MuzeiActivity.this, MuzeiWallpaperService.class))
                        .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
            } catch (ActivityNotFoundException e) {
                try {
                    startActivity(new Intent(WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER)
                            .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
                } catch (ActivityNotFoundException e2) {
                    Toast.makeText(MuzeiActivity.this, R.string.error_wallpaper_chooser, Toast.LENGTH_LONG)
                            .show();
                }
            }
        }
    });
}

From source file:cw.kop.autobackground.sources.SourceListFragment.java

protected void setWallpaper() {

    final Intent intent = new Intent();
    if (Build.VERSION.SDK_INT >= 16) {
        intent.setAction(WallpaperManager.ACTION_CHANGE_LIVE_WALLPAPER);
        final String packageName = LiveWallpaperService.class.getPackage().getName();
        final String className = LiveWallpaperService.class.getCanonicalName();
        intent.putExtra(WallpaperManager.EXTRA_LIVE_WALLPAPER_COMPONENT,
                new ComponentName(packageName, className));
    } else {/* w w  w.jav a  2  s  .  c om*/
        intent.setAction(WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER);
    }

    startActivityForResult(intent, 0);
}