当我尝试从资产设置墙纸时,完成工作需要时间所以也许有更简单的方法而不是我的硬代码
public void Setwallpaper(int position , Context context) throws IOException{
AssetManager am = mContext.getAssets();
nlist = am.list("Gallary");
BufferedInputStream buf = new BufferedInputStream(am.open(nlist[position]));
bitmap = BitmapFactory.decodeStream(buf);
buf.close();
WallpaperManager myWallpaperManager = WallpaperManager
.getInstance(context);
try {
myWallpaperManager.setBitmap(bitmap);
Toast.makeText(context, "Wallpaper set",
0).show();
} catch (IOException e) {
Toast.makeText(context,
"Error setting wallpaper", Toast.LENGTH_SHORT)
.show();
}
}
完成它需要大约 3 秒,而我已经看到其他应用程序能够在不到一秒的时间内完成它任何建议我将不胜感激谢谢