Example usage for android.content Intent ACTION_SET_WALLPAPER

List of usage examples for android.content Intent ACTION_SET_WALLPAPER

Introduction

In this page you can find the example usage for android.content Intent ACTION_SET_WALLPAPER.

Prototype

String ACTION_SET_WALLPAPER

To view the source code for android.content Intent ACTION_SET_WALLPAPER.

Click Source Link

Document

Activity Action: Show settings for choosing wallpaper.

Usage

From source file:com.android.launcher3.Launcher.java

/**
 * Event handler for the wallpaper picker button that appears after a long press
 * on the home screen./*  w w  w. ja v a2s  . com*/
 */
public void onClickWallpaperPicker(View v) {
    if (!Utilities.isWallapaperAllowed(this)) {
        Toast.makeText(this, R.string.msg_disabled_by_admin, Toast.LENGTH_SHORT).show();
        return;
    }

    /*String pickerPackage = getString(R.string.wallpaper_picker_package);
    if (TextUtils.isEmpty(pickerPackage)) {
    pickerPackage =  PackageManagerHelper.getWallpaperPickerPackage(getPackageManager());
    }*/

    int pageScroll = mWorkspace.getScrollForPage(mWorkspace.getPageNearestToCenterOfScreen());
    float offset = mWorkspace.mWallpaperOffset.wallpaperOffsetForScroll(pageScroll);

    setWaitingForResult(new PendingRequestArgs(new ItemInfo()));
    Intent intent = new Intent(Intent.ACTION_SET_WALLPAPER)
            //.setPackage(pickerPackage)
            .putExtra(Utilities.EXTRA_WALLPAPER_OFFSET, offset);
    intent.setSourceBounds(getViewBounds(v));
    startActivityForResult(intent, REQUEST_PICK_WALLPAPER, getActivityLaunchOptions(v));
}

From source file:g7.bluesky.launcher3.Launcher.java

/**
 * Event handler for the wallpaper picker button that appears after a long press
 * on the home screen.//from  w  w w . j  a  v  a 2  s  . c om
 */
protected void onClickWallpaperPicker(View v) {
    if (LOGD)
        Log.d(TAG, "onClickWallpaperPicker");
    final Intent pickWallpaper = new Intent(Intent.ACTION_SET_WALLPAPER);
    pickWallpaper.setComponent(getWallpaperPickerComponent());
    startActivityForResult(pickWallpaper, REQUEST_PICK_WALLPAPER);

    if (mLauncherCallbacks != null) {
        mLauncherCallbacks.onClickWallpaperPicker(v);
    }
}