title: How to set image as wallpaper programmatically?
body: <p>I have been developing the application which need to set an image as wallpaper. </p>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>WallpaperManager m=WallpaperManager.getInstance(this);
  
  String s=Environment.getExternalStorageDirectory().getAbsolutePath()+"/1.jpg";
  File f=new File(s);
  Log.e("exist", String.valueOf(f.exists()));
  try {
          InputStream is=new BufferedInputStream(new FileInputStream(s));
          m.setBitmap(BitmapFactory.decodeFile(s));
  
      } catch (FileNotFoundException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
          Log.e("File", e.getMessage());
      } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
          Log.e("IO", e.getMessage());
      }
  </code></pre>
  
  <p>Also I have added the following permission:</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.SET_WALLPAPER" /&gt;
  </code></pre>
  
  <p>But it doesn't works; the file exists on sdcard. Where have I made a mistake? </p>