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