title: how to get image id of current flipper View and to set that image to user background?
body: <p>This code is working fine but when i try to set current image to user phone background i geting error. Can't figure out how to set a resources from the current image on the screen. how to set this line here        </p>
  
  <pre><code>myWallpaperManager.setResource(vf.indexOfChild(vf.getCurrentView()));   
  </code></pre>
  
  <p>to use current image id of view?</p>
  
  <p>this is the error:
  android.content.res.Resources$NotFoundException: Unable to find resource ID #0x2
  here is my code.</p>
  
  <pre><code>   public class MainActivity extends Activity implements OnGestureListener, OnClickListener {
  
  protected GestureDetector gestureScanner;
  private static final int SWIPE_MIN_DISTANCE = 120;
  private static final int SWIPE_MAX_OFF_PATH = 250;
  private static final int SWIPE_THRESHOLD_VELOCITY = 200;
  private Button next,previous,set;
  private ViewFlipper vf;
  private Animation animFlipInNext,animFlipOutNext, animFlipInPrevious, animFlipOutPrevious;
  
  @SuppressWarnings("deprecation")
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      gestureScanner = new GestureDetector(this);
  
      //vf for viewflipper
      vf=(ViewFlipper)findViewById(R.id.ViewFlipper01);
      animFlipInNext = AnimationUtils.loadAnimation(this, R.anim.flipinnext);
      animFlipOutNext = AnimationUtils.loadAnimation(this, R.anim.flipoutnext);
      animFlipInPrevious = AnimationUtils.loadAnimation(this, R.anim.flipinprevious);
      animFlipOutPrevious = AnimationUtils.loadAnimation(this, R.anim.flipoutprevious);
  
      next = (Button) findViewById(R.id.Button01);
      previous = (Button) findViewById(R.id.Button02);
      set = (Button) findViewById(R.id.set);
      next.setOnClickListener(this);
      previous.setOnClickListener(this);
      set.setOnClickListener(this);
  }
  
  //@Override
  public void onClick(View v) {
      if (v == next) {
          vf.setInAnimation(animFlipInNext);
          vf.setOutAnimation(animFlipOutNext);
          vf.showNext();
      }
      if (v == previous) {
          vf.setInAnimation(animFlipInPrevious);
          vf.setOutAnimation(animFlipOutPrevious);
          vf.showPrevious();
      }
      if(v == set) {
          WallpaperManager myWallpaperManager
          = WallpaperManager.getInstance(getApplicationContext());
         try {
             myWallpaperManager.setResource(R.drawable.arnab); // how to set this line to use the resources of current image on screen?
  
         } catch (IOException e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
         }
         Toast.makeText(getBaseContext(), "Wallpaper is successfully changed", Toast.LENGTH_SHORT).show();
      }
  }
  //this is the part to handle Gesture Listener
  @Override
  public boolean onTouchEvent(MotionEvent me){
      return gestureScanner.onTouchEvent(me);
  }
  public boolean onDown(MotionEvent e){
      return true;
  }
  //FLING gesture listener
  public boolean onFling(MotionEvent e1,MotionEvent e2,float velocityX,float velocityY){
      try {
          if(e1.getX() &gt; e2.getX() &amp;&amp; Math.abs(e1.getX() - e2.getX()) &gt; SWIPE_MIN_DISTANCE &amp;&amp; Math.abs(velocityX) &gt; SWIPE_THRESHOLD_VELOCITY) {
              Toast.makeText(this.getApplicationContext(), "Left", Toast.LENGTH_SHORT).show();
              vf.setInAnimation(animFlipInPrevious);
              vf.setOutAnimation(animFlipOutPrevious);
              vf.showPrevious();
          }else if (e1.getX() &lt; e2.getX() &amp;&amp; e2.getX() - e1.getX() &gt; SWIPE_MIN_DISTANCE &amp;&amp; Math.abs(velocityX) &gt; SWIPE_THRESHOLD_VELOCITY) {
              Toast.makeText(this.getApplicationContext(), "Right", Toast.LENGTH_SHORT).show();
              vf.setInAnimation(animFlipInNext);
              vf.setOutAnimation(animFlipOutNext);
              vf.showNext();
          }
      } catch (Exception e) {
          // nothing
      }
      return true;
  }
  public boolean onScroll(MotionEvent e1,MotionEvent e2,float distanceX,float distanceY){
      return true;
   }
  </code></pre>