【问题标题】:Set wallpaper from file path从文件路径设置壁纸
【发布时间】:2013-11-05 20:29:35
【问题描述】:

我找到了很多关于如何从可绘制对象等设置壁纸的详细信息,但是是否可以从文件位置执行此操作。

我已经确认下面的代码打印出文件的位置

Toast.makeText(MyWallpapers.this, "" + listFile[position].getAbsolutePath(), Toast.LENGTH_SHORT).show();

String ImageLocation = listFile[position].getAbsolutePath();

所以我一直在尝试这样的方法来设置壁纸。

WallpaperManager myWallpaperManager 
        = WallpaperManager.getInstance(getApplicationContext());
try {
    myWallpaperManager.setResource(ImageLocation);
} catch (IOException e) {
    e.printStackTrace();
}

但它不喜欢它。

有什么建议吗?

【问题讨论】:

    标签: java android file path wallpaper


    【解决方案1】:

    使用BitmapFactory 将文件加载到Bitmap 并调用WallpaperManager.setBitmap

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-26
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多