當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。