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