首页 文章

从SDCard上的图像设置壁纸

提问于
浏览
1

如何从SD卡上的图像设置主屏幕壁纸?

即:

try {
    wallpaperManager.setResource("/sdcard/wallpaper/olive.jpg");
    finish();
} catch(IOException e) {
    e.printStackTrace();
}

没有工作,返回一个错误:'WallpaperManager类型中的方法setResource(int)不适用于参数(String)'

1 回答

  • 4
    Bitmap o = BitmapFactory.decodeFile("/sdcard/wallpapers/olive.jpg");
    
    try {
      wallpaperManager.setBitmap(o);
      finish();
    } 
    catch (IOException e) {
      e.printStackTrace();
    }
    

相关问题