从对SD卡的图像设置壁纸 [英] Setting the Wallpaper from an Image on the SDCard

查看:122
本文介绍了从对SD卡的图像设置壁纸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一个人怎么会去从图像设置主屏幕壁纸上的SD卡?

即:

 尝试{
    wallpaperManager.setResource(/ SD卡/壁纸/ olive.jpg);
    完();
}赶上(IOException异常E){
    e.printStackTrace();
}
 

没有工作,返回了一个错误:该方法setResource(INT)在类型WallpaperManager不适用的参数(字符串)

解决方案

 位图O = BitmapFactory.de codeFILE(/ SD卡/壁纸/ olive.jpg);

尝试 {
  wallpaperManager.setBitmap(O);
  完();
}
赶上(IOException异常E){
  e.printStackTrace();
}
 

How would one go about setting the homescreen wallpaper from an image on the SDcard?

i.e.:

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

hasn't worked, returned an error: 'The method setResource(int) in the type WallpaperManager is not applicable for the arguments (String)'

解决方案

Bitmap o = BitmapFactory.decodeFile("/sdcard/wallpapers/olive.jpg");

try {
  wallpaperManager.setBitmap(o);
  finish();
} 
catch (IOException e) {
  e.printStackTrace();
}

这篇关于从对SD卡的图像设置壁纸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆