早上好,我有一个代码可以正确设置壁纸,当我设置壁纸时,它是从网络下载的,大小为 1024 x 768 的 jpg,它分发到所有主屏幕,但从 android 4+ 开始,它们不可滚动,放置一个为所有主屏幕修复了部分图像我想解决这个问题,所以我希望你能帮助我
问候和对不起我英语
//path is a String with image's url
public int setWallpaper(String path) {
int width, height;
Bitmap dbm, bm;
bm = null;
dbm = null;
InputStream is = null;
WallpaperManager wpm = wallpaperManager.getInstance(this);
//all images are 1024x 768
//to scale bitmap the widht have to be 1.33 bigger than screen's height
if((wpm != null) && (dis != null)){
height = dis.getHeight();
width = (int) (height * 1.33);
try {
URLConnection conn = new URL(path).openConnection();
conn.connect();
is = conn.getInputStream();
if (is != null) {
bm = BitmapFactory.decodeStream(new FlushedInputStream(is));
dbm = Bitmap.createScaledBitmap(bm, width, height, false);
wpm.setBitmap(dbm);
}else {
return 2;
}
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (is != null) {
try {
is.close();
}
catch (IOException e) {
e.printStackTrace();
}
}
}
if(bm != null){
bm.recycle();
}
if(dbm != null){
dbm.recycle();
}
}else {
return 1;
}
return 0;
}