2015-04-05 31 views
0

我想從廚房打開圖像,然後將該圖像設置爲手機背景。我可以打開畫廊,但將該圖像設置爲手機背景時出現錯誤。從圖庫中設置手機背景圖片

+0

什麼是錯誤? – Fahim 2015-04-05 15:52:43

+0

@Fahim我越來越畫廊圖像uri但設置背景我使用位圖mBitmap = BitmapFactory.decodeResource(getResources(),id);而不是我應該使用什麼 – Hunt 2015-04-05 16:46:43

+0

檢查我編輯的答案。請提供完整的代碼,以便進一步查看。 – 2015-04-05 17:04:26

回答

1

從imageUri中檢索圖像並將其保存爲位圖對象。確保您擁有Android Manifest中的設置壁紙權限。

Bitmap image =MediaStore.Images.Media.getBitmap(getContentResolver(), imageUri); 

WallpaperManager myWallpaperManager = WallpaperManager.getInstance(getApplicationContext()); 
myWallpaperManager.setBitmap(bitmap); 
+0

我已經這樣做 – Hunt 2015-04-05 16:43:59

+0

thanx它的工作 – Hunt 2015-04-06 12:41:18