Example usage for android.app WallpaperManager EXTRA_LIVE_WALLPAPER_COMPONENT

List of usage examples for android.app WallpaperManager EXTRA_LIVE_WALLPAPER_COMPONENT

Introduction

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

Prototype

String EXTRA_LIVE_WALLPAPER_COMPONENT

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

Click Source Link

Document

Extra in #ACTION_CHANGE_LIVE_WALLPAPER that specifies the ComponentName of a live wallpaper that should be shown as a preview, for the user to confirm.

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.j  av a2  s  . 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: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 {/* ww w .  j  av a2s.co  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   ww  w.  j a v a2  s . com
        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 w w w  .  ja v a2  s . c o m*/
        intent.setAction(WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER);
    }

    startActivityForResult(intent, 0);
}