I have one app that like a Slide show or gallery but i want when anybody use this app be able to set the image to background on android phone
the app can show image i just want to able set image to background - and its can be enough if i can set address of image in Variable and then i can use this Code
WallpaperManager wpm = WallpaperManager.getInstance(getApplicationContext());
try {
wpm.setResource(R.drawable.image_1);
} catch (IOException e) {
e.printStackTrace();
}
Here is a simple tutorial for it. visit this link And if you have imagePath then use following code as :-
is = new FileInputStream(new File(imagePath));
bis = new BufferedInputStream(is);
Bitmap bitmap = BitmapFactory.decodeStream(bis);
Bitmap useThisBitmap = Bitmap.createScaledBitmap(
bitmap, parent.getWidth(), parent.getHeight(), true);
bitmap.recycle();
if(imagePath!=null){
wallpaperManager = WallpaperManager.getInstance(this);
wallpaperDrawable = wallpaperManager.getDrawable();
wallpaperManager.setBitmap(useThisBitmap);
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.