Example usage for android.app WallpaperManager ACTION_LIVE_WALLPAPER_CHOOSER

List of usage examples for android.app WallpaperManager ACTION_LIVE_WALLPAPER_CHOOSER

Introduction

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

Prototype

String ACTION_LIVE_WALLPAPER_CHOOSER

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

Click Source Link

Document

Launch an activity for the user to pick the current global 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//  w  w  w.  java  2s .c  o 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:com.stanleyidesis.quotograph.ui.activity.LWQActivateActivity.java

@OnClick(R.id.button_lwq_activate)
void activate() {
    try {//from   w w w .j a  va  2  s  .  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/*w ww  .j a v  a 2s  .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 {//from  ww w.j ava2s  . c om
        intent.setAction(WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER);
    }

    startActivityForResult(intent, 0);
}