3
我正在开发一个应用程序,显示不同的照片从服务器和用户可以设置选定的照片作为其设备的壁纸我用给定的代码来设置壁纸它的工作,但图像设置不正确,它不适合屏幕。我用这个代码。如何在android中使用编码设置壁纸?
String dirPath = getFilesDir().toString();
String folder = mPhotos.get(nextPosition - 1).getCategory();
String filePath = dirPath + "/PhotoViewer/" + folder + "/"
+ mPhotos.get(nextPosition - 1).getFileName();
File imageFile = new File(filePath);
Bitmap bitmap = BitmapFactory.decodeFile(imageFile
.getAbsolutePath());
WallpaperManager myWallpaperManager = WallpaperManager
.getInstance(getApplicationContext());
try {
myWallpaperManager.setBitmap(bitmap);
Toast.makeText(PhotoActivity.this, "Wallpaper set",
Toast.LENGTH_SHORT).show();
} catch (IOException e) {
Toast.makeText(PhotoActivity.this, "Error setting wallpaper",
Toast.LENGTH_SHORT).show();
}
请帮我一把。
calculateInSampleSize(选项,宽度,高度);这是什么 ?这个函数显示你在代码中没有提到这个函数的错误。 – nishitpatel 2013-04-09 04:23:27