Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/181.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 从文件路径设置壁纸_Java_Android_File_Path_Wallpaper - Fatal编程技术网

Java 从文件路径设置壁纸

Java 从文件路径设置壁纸,java,android,file,path,wallpaper,Java,Android,File,Path,Wallpaper,我已经找到了很多关于如何从一个可绘制的等设置墙纸的细节,但是可以从一个文件位置这样做 我已经确认以下代码打印出了文件的位置 Toast.makeText(MyWallpapers.this, "" + listFile[position].getAbsolutePath(), Toast.LENGTH_SHORT).show(); String ImageLocation = listFile[position].getAbsolutePath(); 所以我一直在尝试这样的东西,让它来设置壁

我已经找到了很多关于如何从一个可绘制的等设置墙纸的细节,但是可以从一个文件位置这样做

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

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();
}
但它不喜欢它

有什么建议吗?

将文件加载到using and call中

将文件加载到using and call中