本文整理汇总了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);
}
示例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;
}
示例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();
}
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例8: refreshWallpaper
import android.app.WallpaperManager; //导入方法依赖的package包/类
private void refreshWallpaper () {
final WallpaperManager wallpaperManager = WallpaperManager.getInstance(this);
final Drawable wallpaperDrawable = wallpaperManager.getDrawable();
mCoverIv.setImageDrawable(wallpaperDrawable);
}
示例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());
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}