类android.app.WallpaperInfo源码实例Demo

下面列出了怎么用android.app.WallpaperInfo的API类实例代码及写法,或者点击链接到github查看源代码。

@Override
public WallpaperInfo getWallpaperInfo(int userId) {
    userId = ActivityManager.handleIncomingUser(Binder.getCallingPid(),
            Binder.getCallingUid(), userId, false, true, "getWallpaperInfo", null);
    synchronized (mLock) {
        WallpaperData wallpaper = mWallpaperMap.get(userId);
        if (wallpaper != null && wallpaper.connection != null) {
            return wallpaper.connection.mInfo;
        }
        return null;
    }
}
 
源代码2 项目: alynx-live-wallpaper   文件: MainActivity.java
@Override
public void onApplyButtonClicked(@NonNull final WallpaperCard wallpaperCard) {
    final WallpaperInfo info = WallpaperManager.getInstance(this).getWallpaperInfo();
    if (info == null || !Objects.equals(info.getPackageName(), getPackageName())) {
        final AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.choose_wallpaper_title);
        builder.setMessage(R.string.choose_wallpaper);
        builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int id) {
                // Only after user click OK, we change currentWallpaperCard.
                LWApplication.setCurrentWallpaperCard(getApplicationContext(), wallpaperCard);
                cardAdapter.notifyDataSetChanged();
                LWApplication.setPreviewWallpaperCard(wallpaperCard);
                Intent intent = new Intent(WallpaperManager.ACTION_LIVE_WALLPAPER_CHOOSER);
                startActivity(intent);
            }
        });
        addDialog = builder.create();
        addDialog.show();
    } else {
        LWApplication.setCurrentWallpaperCard(this, wallpaperCard);
        cardAdapter.notifyDataSetChanged();
        // Display a notice for user.
        Snackbar.make(
            coordinatorLayout,
            String.format(
                getResources().getString(R.string.applied_wallpaper),
                wallpaperCard.getName()
            ),
            Snackbar.LENGTH_LONG
        ).show();
    }
}
 
源代码3 项目: Status   文件: StatusView.java
public void setTransparent() {
    if (backgroundImage == null) {
        Drawable backgroundDrawable;
        WallpaperInfo wallpaperInfo = wallpaperManager.getWallpaperInfo();
        if (wallpaperInfo != null)
            backgroundDrawable = wallpaperInfo.loadThumbnail(getContext().getPackageManager());
        else {
            try {
                backgroundDrawable = wallpaperManager.getDrawable();
            } catch (SecurityException e) {
                setColor(getDefaultColor());
                return;
            }
        }

        backgroundImage = ImageUtils.cropBitmapToBar(getContext(), me.jfenn.androidutils.ImageUtils.drawableToBitmap(backgroundDrawable));
    }

    if (backgroundImage != null) {
        int color = ColorUtils.getAverageColor(backgroundImage);

        setColor(color);
        if (isTransparentHome)
            needsBackgroundImageDraw = true;
        else backgroundImage = null;
    } else setColor(backgroundColor.getDefault());

    postInvalidate();
}
 
源代码4 项目: TurboLauncher   文件: WallpaperPickerActivity.java
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == IMAGE_PICK && resultCode == RESULT_OK) {
        if (data != null && data.getData() != null) {
            Uri uri = data.getData();
            addTemporaryWallpaperTile(uri, false);
        }
    } else if (requestCode == PICK_WALLPAPER_THIRD_PARTY_ACTIVITY) {
        setResult(RESULT_OK);
        finish();
    } else if (requestCode == PICK_LIVE_WALLPAPER) {
        WallpaperManager wm = WallpaperManager.getInstance(this);
        final WallpaperInfo oldLiveWallpaper = mLiveWallpaperInfoOnPickerLaunch;
        final WallpaperInfo clickedWallpaper = mLastClickedLiveWallpaperInfo;
        WallpaperInfo newLiveWallpaper = wm.getWallpaperInfo();
        // Try to figure out if a live wallpaper was set;
        if (newLiveWallpaper != null &&
                (oldLiveWallpaper == null
                        || !oldLiveWallpaper.getComponent()
                                .equals(newLiveWallpaper.getComponent())
                        || clickedWallpaper.getComponent()
                                .equals(oldLiveWallpaper.getComponent()))) {
            // Return if a live wallpaper was set
            setResult(RESULT_OK);
            finish();
        }
    }
}
 
源代码5 项目: LB-Launcher   文件: WallpaperPickerActivity.java
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == IMAGE_PICK && resultCode == RESULT_OK) {
        if (data != null && data.getData() != null) {
            Uri uri = data.getData();
            addTemporaryWallpaperTile(uri, false);
        }
    } else if (requestCode == PICK_WALLPAPER_THIRD_PARTY_ACTIVITY) {
        setResult(RESULT_OK);
        finish();
    } else if (requestCode == PICK_LIVE_WALLPAPER) {
        WallpaperManager wm = WallpaperManager.getInstance(this);
        final WallpaperInfo oldLiveWallpaper = mLiveWallpaperInfoOnPickerLaunch;
        final WallpaperInfo clickedWallpaper = mLastClickedLiveWallpaperInfo;
        WallpaperInfo newLiveWallpaper = wm.getWallpaperInfo();
        // Try to figure out if a live wallpaper was set;
        if (newLiveWallpaper != null &&
                (oldLiveWallpaper == null
                        || !oldLiveWallpaper.getComponent()
                                .equals(newLiveWallpaper.getComponent())
                        || clickedWallpaper.getComponent()
                                .equals(oldLiveWallpaper.getComponent()))) {
            // Return if a live wallpaper was set
            setResult(RESULT_OK);
            finish();
        }
    }
}
 
public WallpaperConnection(WallpaperInfo info, WallpaperData wallpaper) {
    mInfo = info;
    mWallpaper = wallpaper;
}
 
源代码7 项目: Trebuchet   文件: LiveWallpaperListAdapter.java
public LiveWallpaperTile(Drawable thumbnail, WallpaperInfo info, Intent intent) {
    mThumbnail = thumbnail;
    mInfo = info;
}
 
源代码8 项目: TurboLauncher   文件: WallpaperPickerActivity.java
public void onLiveWallpaperPickerLaunch(WallpaperInfo info) {
    mLastClickedLiveWallpaperInfo = info;
    mLiveWallpaperInfoOnPickerLaunch = WallpaperManager.getInstance(this).getWallpaperInfo();
}
 
源代码9 项目: TurboLauncher   文件: LiveWallpaperListAdapter.java
public LiveWallpaperTile(Drawable thumbnail, WallpaperInfo info, Intent intent) {
    mThumbnail = thumbnail;
    mInfo = info;
}
 
源代码10 项目: earth   文件: WallpaperUtil.java
static boolean isCurrent(Context context) {
    WallpaperManager wm = WallpaperManager.getInstance(context);
    WallpaperInfo wi = wm.getWallpaperInfo();
    return wi != null && new ComponentName(context, EarthWallpaperService.class)
            .equals(wi.getComponent());
}
 
源代码11 项目: LB-Launcher   文件: WallpaperPickerActivity.java
public void onLiveWallpaperPickerLaunch(WallpaperInfo info) {
    mLastClickedLiveWallpaperInfo = info;
    mLiveWallpaperInfoOnPickerLaunch = WallpaperManager.getInstance(this).getWallpaperInfo();
}
 
源代码12 项目: LB-Launcher   文件: LiveWallpaperListAdapter.java
public LiveWallpaperTile(Drawable thumbnail, WallpaperInfo info, Intent intent) {
    mThumbnail = thumbnail;
    mInfo = info;
}
 
源代码13 项目: LiveWallpaper   文件: WallpaperUtil.java
/**
 * 判断是否是使用我们的壁纸
 *
 * @param paramContext
 * @return
 */
public static boolean wallpaperIsUsed(Context paramContext) {
    WallpaperInfo localWallpaperInfo = WallpaperManager.getInstance(paramContext).getWallpaperInfo();
    return ((localWallpaperInfo != null) && (localWallpaperInfo.getPackageName().equals(paramContext.getPackageName())) &&
            (localWallpaperInfo.getServiceName().equals(LiveWallpaperService.class.getCanonicalName())));
}
 
 类所在包
 同包方法