9

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();
}

1 Answer 1

0

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);
    }

Not the answer you're looking for? Browse other questions tagged or ask your own question.