当前位置: 首页>>代码示例>>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;未经允许,请勿转载。