當前位置: 首頁>>代碼示例>>Java>>正文


Java WallpaperManager.getDrawable方法代碼示例

本文整理匯總了Java中android.app.WallpaperManager.getDrawable方法的典型用法代碼示例。如果您正苦於以下問題:Java WallpaperManager.getDrawable方法的具體用法?Java WallpaperManager.getDrawable怎麽用?Java WallpaperManager.getDrawable使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.app.WallpaperManager的用法示例。


在下文中一共展示了WallpaperManager.getDrawable方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getBackground

import android.app.WallpaperManager; //導入方法依賴的package包/類
public static BitmapDrawable getBackground(Context context) {

        WallpaperManager wallpaperManager = WallpaperManager
                .getInstance(context);
        // 獲取當前壁紙
        Drawable wallpaperDrawable = wallpaperManager.getDrawable();
        // 將Drawable,轉成Bitmap
        Bitmap bm = ((BitmapDrawable) wallpaperDrawable).getBitmap();
        float step = 0;
        // 計算出屏幕的偏移量
        step = (bm.getWidth() - 480) / (7 - 1);
        // 截取相應屏幕的Bitmap
        DisplayMetrics dm = new DisplayMetrics();
        Bitmap pbm = Bitmap.createBitmap(bm, (int) (5 * step), 0,
                dm.widthPixels, dm.heightPixels);

        return new BitmapDrawable(pbm);
    }
 
開發者ID:BigAppOS,項目名稱:BigApp_Discuz_Android,代碼行數:19,代碼來源:SystemBitmap.java

示例2: getWallpaperDrawableWithSizeDrawable

import android.app.WallpaperManager; //導入方法依賴的package包/類
public static Drawable getWallpaperDrawableWithSizeDrawable(Context context,
                                                            int width, int height, int alpha) {

    WallpaperManager wallpaperManager = WallpaperManager
            .getInstance(context);
    // 獲取當前壁紙
    Drawable wallpaperDrawable = wallpaperManager.getDrawable();
    // 將Drawable,轉成Bitmap
    Bitmap bm = ((BitmapDrawable) wallpaperDrawable).getBitmap();
    bm = BitmapUtils.getAdpterBitmap(bm, width, height);
    Drawable d = BitmapUtils.Bitmap2Drawable(bm);
    bm = BitmapUtils.setAlpha(bm, alpha);
    if (bm != null && bm.isRecycled()) {
        bm.recycle();
    }
    return d;
}
 
開發者ID:BigAppOS,項目名稱:BigApp_Discuz_Android,代碼行數:18,代碼來源:SystemBitmap.java

示例3: storeLastWallpaper

import android.app.WallpaperManager; //導入方法依賴的package包/類
private void storeLastWallpaper() throws IOException {
    Context context = contextWeakReference.get();
    WallpaperManager wallpaperMgr = WallpaperManager.getInstance(context);
    File lastWallpaperFile = new File(context.getFilesDir(), LAST_WALLPAPER_FILE_NAME);
    if (!lastWallpaperFile.createNewFile()) {
        lastWallpaperFile.delete();
        lastWallpaperFile.createNewFile();
    }
    if (wallpaperMgr.getDrawable() instanceof BitmapDrawable) {
        FileOutputStream outputStream = context.openFileOutput(LAST_WALLPAPER_FILE_NAME,
                Context.MODE_PRIVATE);
        ((BitmapDrawable)wallpaperMgr.getDrawable()).getBitmap().compress(
                Bitmap.CompressFormat.PNG, 100, outputStream);
        outputStream.close();
    }
}
 
開發者ID:danielgimenes,項目名稱:NasaPic,代碼行數:17,代碼來源:SpacePicInteractor.java

示例4: initBg

import android.app.WallpaperManager; //導入方法依賴的package包/類
private void initBg() {
    // 獲取壁紙管理器
    WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
    Drawable drawable = wallpaperManager.getDrawable();
    // 獲取當前壁紙
    Drawable wallpaperDrawable = wallpaperManager.getDrawable();
    // 將Drawable,轉成Bitmap
    Bitmap bm = ((BitmapDrawable) wallpaperDrawable).getBitmap();
    splashBg.setImageBitmap(bm);
}
 
開發者ID:lpy19930103,項目名稱:MinimalismJotter,代碼行數:11,代碼來源:SplashActivity.java

示例5: getWallpaper

import android.app.WallpaperManager; //導入方法依賴的package包/類
public static Bitmap getWallpaper(Context context) {

        WallpaperManager wallpaperManager = WallpaperManager
                .getInstance(context);
        // 獲取當前壁紙
        Drawable wallpaperDrawable = wallpaperManager.getDrawable();
        // 將Drawable,轉成Bitmap
        Bitmap bm = ((BitmapDrawable) wallpaperDrawable).getBitmap();

        return bm;
        // return new BitmapDrawable(bm);
    }
 
開發者ID:BigAppOS,項目名稱:BigApp_Discuz_Android,代碼行數:13,代碼來源:SystemBitmap.java

示例6: getWallpaperDrawable

import android.app.WallpaperManager; //導入方法依賴的package包/類
public static Drawable getWallpaperDrawable(Context context) {

        WallpaperManager wallpaperManager = WallpaperManager
                .getInstance(context);
        // 獲取當前壁紙
        Drawable wallpaperDrawable = wallpaperManager.getDrawable();
        // 將Drawable,轉成Bitmap
        Bitmap bm = ((BitmapDrawable) wallpaperDrawable).getBitmap();
        Drawable d = BitmapUtils.Bitmap2Drawable(bm);
        if (bm != null && bm.isRecycled()) {
            bm.recycle();
        }
        return d;

    }
 
開發者ID:BigAppOS,項目名稱:BigApp_Discuz_Android,代碼行數:16,代碼來源:SystemBitmap.java

示例7: getWallpaperDrawableWithSizeBitmap

import android.app.WallpaperManager; //導入方法依賴的package包/類
public static Bitmap getWallpaperDrawableWithSizeBitmap(Context context,
                                                        int width, int height, int alpha) {

    WallpaperManager wallpaperManager = WallpaperManager
            .getInstance(context);
    // 獲取當前壁紙
    Drawable wallpaperDrawable = wallpaperManager.getDrawable();
    // 將Drawable,轉成Bitmap
    Bitmap bm = ((BitmapDrawable) wallpaperDrawable).getBitmap();
    bm = BitmapUtils.getAdpterBitmap(bm, width, height);
    bm = BitmapUtils.setAlpha(bm, alpha);

    return bm;
}
 
開發者ID:BigAppOS,項目名稱:BigApp_Discuz_Android,代碼行數:15,代碼來源:SystemBitmap.java

示例8: refreshWallpaper

import android.app.WallpaperManager; //導入方法依賴的package包/類
private void refreshWallpaper () {
    final WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
    final Drawable wallpaperDrawable = wallpaperManager.getDrawable();
    mCoverIv.setImageDrawable(wallpaperDrawable);
}
 
開發者ID:boybeak,項目名稱:DelegateAdapter,代碼行數:6,代碼來源:MainActivity.java

示例9: setSystemAsBackground

import android.app.WallpaperManager; //導入方法依賴的package包/類
private void setSystemAsBackground(final Context context) {
	WallpaperManager wallpaperManager = WallpaperManager.getInstance(context);
	final Drawable wallpaperDrawable = wallpaperManager.getDrawable();

	final BitmapDrawable wallpaperBitmap = (BitmapDrawable) wallpaperDrawable;
	setBackgroundImage(context, wallpaperBitmap.getBitmap());
}
 
開發者ID:SebastianRask,項目名稱:Astro-Lockscreen,代碼行數:8,代碼來源:ParallaxBackground.java

示例10: getWallpaperBitmap

import android.app.WallpaperManager; //導入方法依賴的package包/類
/**
 * @return The {@link Bitmap} for the current wallpaper, or null if none exists.
 */
public static Bitmap getWallpaperBitmap(WallpaperManager wManager, Context mContext) {
    if (null == wManager || null == mContext) return null;
    final Bitmap wallpaper = getCurrentWallpaperLocked(wManager, mContext);
    if (null != wallpaper) return wallpaper;
    final Drawable wallpaperD = wManager.getDrawable();
    if (null != wallpaperD) {
        return drawableToBitmap(wallpaperD);
    }
    return null;
}
 
開發者ID:Tombarr,項目名稱:Noyze,代碼行數:14,代碼來源:Utils.java

示例11: getAppWallpaper

import android.app.WallpaperManager; //導入方法依賴的package包/類
public void getAppWallpaper()
{
    // Gotten from stack to set background as system background
    WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
    Drawable wallpaperDrawable = (Drawable) wallpaperManager.getDrawable();

    //Do cropping of the wallpaper so it doesn't look smushed
    Bitmap bitmap = ((BitmapDrawable) wallpaperDrawable).getBitmap();

    //Get our display size
    Display display = getWindowManager().getDefaultDisplay();
    Point size = new Point();
    display.getSize(size);
    int width = size.x;
    int height = size.y;

    //crop from center to screensize
    bitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height);

    //Set wallpaper to bitmap
    wallpaperDrawable = new BitmapDrawable(getResources(),bitmap);

    // Darken
    wallpaperDrawable.setColorFilter(
            getResources().getColor(R.color.transparent),
            PorterDuff.Mode.SRC_ATOP);
    getWindow().setBackgroundDrawable(wallpaperDrawable);
}
 
開發者ID:torch2424,項目名稱:Feather,代碼行數:29,代碼來源:FeatherSettings.java

示例12: getAppWallpaper

import android.app.WallpaperManager; //導入方法依賴的package包/類
public void getAppWallpaper()
{
	// Gotten from stack to set background as system background
	WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
	Drawable wallpaperDrawable = (Drawable) wallpaperManager.getDrawable();
	
	//Do cropping of the wallpaper so it doesn't look smushed
	Bitmap bitmap = ((BitmapDrawable) wallpaperDrawable).getBitmap();
	
	//Get our display size
	Display display = getWindowManager().getDefaultDisplay();
	Point size = new Point();
	display.getSize(size);
	int width = size.x;
	int height = size.y;
	
	//crop from center to screensize
	bitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height);
	
	//Set wallpaper to bitmap
	wallpaperDrawable = new BitmapDrawable(getResources(),bitmap);
	
	// Darken
	wallpaperDrawable.setColorFilter(
			getResources().getColor(R.color.transparent),
			PorterDuff.Mode.SRC_ATOP);
	getWindow().setBackgroundDrawable(wallpaperDrawable);
}
 
開發者ID:torch2424,項目名稱:Feather,代碼行數:29,代碼來源:EditPlaylist.java

示例13: getAppWallpaper

import android.app.WallpaperManager; //導入方法依賴的package包/類
public void getAppWallpaper()
{
	// Gotten from stack to set background as system background
	WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
	Drawable wallpaperDrawable = (Drawable) wallpaperManager.getDrawable();
	
	// Do cropping of the wallpaper so it doesn't look smushed
	Bitmap bitmap = ((BitmapDrawable) wallpaperDrawable).getBitmap();
	
	// Get our display size
	Display display = getWindowManager().getDefaultDisplay();
	Point size = new Point();
	display.getSize(size);
	int width = size.x;
	int height = size.y;
	
	// crop from center to screensize
	bitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height);
	
	// Set wallpaper to bitmap
	wallpaperDrawable = new BitmapDrawable(getResources(), bitmap);
	
	// Darken
	wallpaperDrawable.setColorFilter(
			getResources().getColor(R.color.transparent),
			PorterDuff.Mode.SRC_ATOP);
	getWindow().setBackgroundDrawable(wallpaperDrawable);
}
 
開發者ID:torch2424,項目名稱:Feather,代碼行數:29,代碼來源:Ui.java


注:本文中的android.app.WallpaperManager.getDrawable方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。