本文整理匯總了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);
}