Friday, 1 June 2012

Set Bitmap as Wallpaper in android


void SetWallpaper(Bitmap b)
   {  
    Bitmap bmImg = b;  
    try {      
    String filepath=Environment.getExternalStorageDirectory().getAbsolutePath();
    FileOutputStream fos = new FileOutputStream(filepath + "/" + "output.jpg");
    bmImg.compress(CompressFormat.JPEG, 75, fos);  
    fos.flush();    
    fos.close();      
    Context context = this.getBaseContext();
    context.setWallpaper(bmImg);
    MessageBox("Image set as Wallpaper");
    }
    catch (Exception e)
    {      
    e.printStackTrace();  
    }
   }

No comments:

Post a Comment