当前位置: 首页>>代码示例>>Java>>正文


Java WallpaperManager.getWallpaperInfo方法代码示例

本文整理汇总了Java中android.app.WallpaperManager.getWallpaperInfo方法的典型用法代码示例。如果您正苦于以下问题:Java WallpaperManager.getWallpaperInfo方法的具体用法?Java WallpaperManager.getWallpaperInfo怎么用?Java WallpaperManager.getWallpaperInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.app.WallpaperManager的用法示例。


在下文中一共展示了WallpaperManager.getWallpaperInfo方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: initSetWallpaperPrompt

import android.app.WallpaperManager; //导入方法依赖的package包/类
/**
 * Prompt the user to set our app as live wallpaper if the user has not set it.
 */
private void initSetWallpaperPrompt() {
    final WallpaperManager wm = WallpaperManager.getInstance(getApplicationContext());
    if ((wm.getWallpaperInfo() != null && wm.getWallpaperInfo().getPackageName().equalsIgnoreCase(getPackageName()))) {
        // We are good
    } else {
        // Ask user.
        Snackbar.make(binding.coordinatorLayout, R.string.set_live_wallpaper_promt, Snackbar.LENGTH_INDEFINITE)
                .setAction(android.R.string.ok, new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        launchSetWallpaperScreen();
                    }
                }).show();
    }
}
 
开发者ID:arunkumar9t2,项目名称:chameleon-live-wallpaper,代码行数:19,代码来源:MainActivity.java

示例2: isWallpaperActivated

import android.app.WallpaperManager; //导入方法依赖的package包/类
public static boolean isWallpaperActivated() {
    final WallpaperManager wallpaperManager = WallpaperManager.getInstance(sApplication);
    final WallpaperInfo wallpaperInfo = wallpaperManager.getWallpaperInfo();
    boolean active = wallpaperInfo != null && sApplication.getPackageName().equalsIgnoreCase(wallpaperInfo.getPackageName());
    LWQLoggerHelper.get().logWallpaperActive(active);
    return active;
}
 
开发者ID:stanidesis,项目名称:quotograph,代码行数:8,代码来源:LWQApplication.java

示例3: onActivityResult

import android.app.WallpaperManager; //导入方法依赖的package包/类
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();
        }
    }
}
 
开发者ID:Phonemetra,项目名称:TurboLauncher,代码行数:28,代码来源:WallpaperPickerActivity.java

示例4: setWallpaper

import android.app.WallpaperManager; //导入方法依赖的package包/类
private void setWallpaper() {
    final WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
    final WallpaperInfo wallpaperInfo = wallpaperManager.getWallpaperInfo();

    String wallpaperId;
    if (isCustom) {
        wallpaperId = Constants.BG_CUSTOM_ID;
    } else {
        wallpaperId = catalogItem.getId();
    }

    sharedPreferences.edit().putString(PREF_BACKGROUND, wallpaperId).apply();

    boolean zeroAsLive = true;

    // Check if Zero is the current live wallpaper
    if (wallpaperInfo == null) {
        zeroAsLive = false;
    } else {
        if (!wallpaperInfo.getServiceName().equals(SERVICE_NAME)) {
            zeroAsLive = false;
        }
    }

    if (!zeroAsLive) {
        // Show dialog
        new AlertDialog.Builder(this)
                .setTitle(R.string.set_dialog_notzero_title)
                .setMessage(R.string.set_dialog_notzero_message)
                .setPositiveButton(R.string.common_ok, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        // Show live-wallpaper preview
                        openLWSetter(context);
                    }
                })
                .setNegativeButton(R.string.common_cancel, null)
                .show();
    } else {
        Toast.makeText(context, R.string.set_alert_changed, Toast.LENGTH_SHORT).show();
    }
}
 
开发者ID:lucasax,项目名称:Zero,代码行数:43,代码来源:SetActivity.java

示例5: onHandleIntent

import android.app.WallpaperManager; //导入方法依赖的package包/类
@Override
protected void onHandleIntent(Intent intent) {
    WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
    int wallpaperId = ExtractionUtils.getWallpaperId(wallpaperManager);
    ExtractedColors extractedColors = new ExtractedColors();
    if (wallpaperManager.getWallpaperInfo() != null) {
        // We can't extract colors from live wallpapers, so just use the default color always.
        extractedColors.updatePalette(null);
        extractedColors.updateHotseatPalette(null);
    } else {
        Bitmap wallpaper = ((BitmapDrawable) wallpaperManager.getDrawable()).getBitmap();
        Palette palette = Palette.from(wallpaper).generate();
        extractedColors.updatePalette(palette);
        // We extract colors for the hotseat and status bar separately,
        // since they only consider part of the wallpaper.
        Palette hotseatPalette = Palette.from(wallpaper)
                .setRegion(0, (int) (wallpaper.getHeight() * (1f - HOTSEAT_FRACTION)),
                        wallpaper.getWidth(), wallpaper.getHeight())
                .clearFilters()
                .generate();
        extractedColors.updateHotseatPalette(hotseatPalette);

        if (FeatureFlags.LIGHT_STATUS_BAR) {
            int statusBarHeight = getResources()
                    .getDimensionPixelSize(R.dimen.status_bar_height);
            Palette statusBarPalette = Palette.from(wallpaper)
                    .setRegion(0, 0, wallpaper.getWidth(), statusBarHeight)
                    .clearFilters()
                    .generate();
            extractedColors.updateStatusBarPalette(statusBarPalette);
        }
    }

    // Save the extracted colors and wallpaper id to LauncherProvider.
    String colorsString = extractedColors.encodeAsString();
    Bundle extras = new Bundle();
    extras.putInt(LauncherSettings.Settings.EXTRA_WALLPAPER_ID, wallpaperId);
    extras.putString(LauncherSettings.Settings.EXTRA_EXTRACTED_COLORS, colorsString);
    getContentResolver().call(
            LauncherSettings.Settings.CONTENT_URI,
            LauncherSettings.Settings.METHOD_SET_EXTRACTED_COLORS_AND_WALLPAPER_ID,
            null, extras);
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:44,代码来源:ColorExtractionService.java

示例6: isCurrent

import android.app.WallpaperManager; //导入方法依赖的package包/类
public 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());
}
 
开发者ID:oxoooo,项目名称:earth,代码行数:7,代码来源:WallpaperUtil.java


注:本文中的android.app.WallpaperManager.getWallpaperInfo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。