本文整理汇总了Java中android.app.WallpaperManager.suggestDesiredDimensions方法的典型用法代码示例。如果您正苦于以下问题:Java WallpaperManager.suggestDesiredDimensions方法的具体用法?Java WallpaperManager.suggestDesiredDimensions怎么用?Java WallpaperManager.suggestDesiredDimensions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.WallpaperManager
的用法示例。
在下文中一共展示了WallpaperManager.suggestDesiredDimensions方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: suggestWallpaperDimension
import android.app.WallpaperManager; //导入方法依赖的package包/类
public static void suggestWallpaperDimension(Resources res,
final SharedPreferences sharedPrefs,
WindowManager windowManager,
final WallpaperManager wallpaperManager, boolean fallBackToDefaults) {
final Point defaultWallpaperSize = WallpaperUtils.getDefaultWallpaperSize(res, windowManager);
// If we have saved a wallpaper width/height, use that instead
int savedWidth = sharedPrefs.getInt(WALLPAPER_WIDTH_KEY, -1);
int savedHeight = sharedPrefs.getInt(WALLPAPER_HEIGHT_KEY, -1);
if (savedWidth == -1 || savedHeight == -1) {
if (!fallBackToDefaults) {
return;
} else {
savedWidth = defaultWallpaperSize.x;
savedHeight = defaultWallpaperSize.y;
}
}
if (savedWidth != wallpaperManager.getDesiredMinimumWidth() ||
savedHeight != wallpaperManager.getDesiredMinimumHeight()) {
wallpaperManager.suggestDesiredDimensions(savedWidth, savedHeight);
}
}
示例2: suggestWallpaperDimension
import android.app.WallpaperManager; //导入方法依赖的package包/类
static public void suggestWallpaperDimension(Resources res,
final SharedPreferences sharedPrefs,
WindowManager windowManager,
final WallpaperManager wallpaperManager, boolean fallBackToDefaults) {
final Point defaultWallpaperSize = getDefaultWallpaperSize(res, windowManager);
// If we have saved a wallpaper width/height, use that instead
int savedWidth = sharedPrefs.getInt(WALLPAPER_WIDTH_KEY, -1);
int savedHeight = sharedPrefs.getInt(WALLPAPER_HEIGHT_KEY, -1);
if (savedWidth == -1 || savedHeight == -1) {
if (!fallBackToDefaults) {
return;
} else {
savedWidth = defaultWallpaperSize.x;
savedHeight = defaultWallpaperSize.y;
}
}
if (savedWidth != wallpaperManager.getDesiredMinimumWidth() ||
savedHeight != wallpaperManager.getDesiredMinimumHeight()) {
wallpaperManager.suggestDesiredDimensions(savedWidth, savedHeight);
}
}
示例3: suggestWallpaperDimension
import android.app.WallpaperManager; //导入方法依赖的package包/类
static public void suggestWallpaperDimension(Resources res,
final SharedPreferences sharedPrefs,
WindowManager windowManager,
final WallpaperManager wallpaperManager) {
final Point defaultWallpaperSize = getDefaultWallpaperSize(res, windowManager);
// If we have saved a wallpaper width/height, use that instead
int savedWidth = sharedPrefs.getInt(WALLPAPER_WIDTH_KEY, defaultWallpaperSize.x);
int savedHeight = sharedPrefs.getInt(WALLPAPER_HEIGHT_KEY, defaultWallpaperSize.y);
if (savedWidth != wallpaperManager.getDesiredMinimumWidth() ||
savedHeight != wallpaperManager.getDesiredMinimumHeight()) {
wallpaperManager.suggestDesiredDimensions(savedWidth, savedHeight);
}
}
示例4: doInBackground
import android.app.WallpaperManager; //导入方法依赖的package包/类
@Override
protected Void doInBackground(Object... objects) {
DisplayMetrics metrics = new DisplayMetrics();
getActivity().getWindowManager().getDefaultDisplay().getMetrics(metrics);
int height = metrics.heightPixels;
int width = metrics.widthPixels;
WallpaperManager wallpaperManager = WallpaperManager.getInstance(getActivity());
wallpaperManager.setWallpaperOffsetSteps(1, 1);
wallpaperManager.suggestDesiredDimensions(width, height);
try {
String urlWalpaper = urlImage.replace("/r_10000_" + getActivity().getResources().getInteger(R.integer.fragment_movie_fond_height), "/r_" + (width) + "_" + (height));
wallpaperManager.setStream(new URL(urlWalpaper).openStream());
/* Bitmap bmap2 = BitmapFactory.decodeStream(new URL(urlWalpaper).openStream());
DisplayMetrics metrics = new DisplayMetrics();
activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
int height = metrics.heightPixels;
int width = metrics.widthPixels;
Bitmap bitmap = Bitmap.createScaledBitmap(bmap2, width, height, true);
activity.setWallpaper(bitmap);
// wallpaperManager.setBitmap(bitmap);
*/
} catch (Exception e) {
if (e.getMessage() != null)
e.printStackTrace();
}
return null;
}