title: How to set wallpaper to whole screen of device in android
body: <p>I am using set as wallpaper in my android app. But when I set image as wallpaper its zoom upto some extent on device. I want when I set image as wallpaper. This fit on every screen device. I am using DisplayMetrices but its not working perfect.</p>
  
  <p>Code-</p>
  
  <pre><code>   public class FullImageActivity extends Activity {
  
      int position, width, height;
      LinearLayout full;
      Button btn;
      Context context;
      DisplayMetrics metrics;
  
      public Integer[] mThumbId = {
                  R.drawable.kri1, R.drawable.kri2,
                  R.drawable.kri3, R.drawable.kri4,
                  R.drawable.kri5, R.drawable.kri6,
                  R.drawable.kri7, R.drawable.kri8,
                  R.drawable.kri9
      };
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.full_image);
  
          // get intent data
          Intent i = getIntent();
  
          // Selected image id
          position = i.getExtras().getInt("id");        
          full = (LinearLayout) findViewById(R.id.full);
          btn = (Button)findViewById(R.id.btn);
          changeBackground();
          metrics = this.getResources().getDisplayMetrics();
          width = metrics.widthPixels;
          height = metrics.heightPixels;
          btn.setOnClickListener(new Button.OnClickListener(){
              @Override
              public void onClick(View arg0) {
              WallpaperManager myWallpaperManager = WallpaperManager.getInstance(getApplicationContext());
              try {
                  myWallpaperManager.suggestDesiredDimensions(width, height);
                  myWallpaperManager.setResource(mThumbId[position]);
              } catch (IOException e) {
                  e.printStackTrace();
             }
          }});
          ActivitySwipeDetector activitySwipeDetector = new ActivitySwipeDetector(this);
          full.setOnTouchListener(activitySwipeDetector);
      }
  
      private void changeBackground(){
          full.setBackgroundResource(mThumbId[position]);
     }
  
      public class ActivitySwipeDetector implements View.OnTouchListener {
  
          static final String logTag = "ActivitySwipeDetector";
          static final int MIN_DISTANCE = 100;
          private float downX, upX;
          Activity activity;
  
          public ActivitySwipeDetector(Activity activity){
              this.activity = activity;
          }
  
          public void onRightToLeftSwipe(){
              Log.i(logTag, "RightToLeftSwipe!");
              if(position &lt; mThumbId.length - 1){
                  position++;
                   changeBackground();
              }
      }
  
          public void onLeftToRightSwipe(){
              Log.i(logTag, "LeftToRightSwipe!");
              if(position &gt; 0){
                  position--;
                  changeBackground();
             }
          }
  
          public boolean onTouch(View v, MotionEvent event) {
              switch(event.getAction()){
                  case MotionEvent.ACTION_DOWN: {
                      downX = event.getX();
                      return true;
                  }
                  case MotionEvent.ACTION_UP: {
                      upX = event.getX();
  
                      float deltaX = downX - upX;
  
                      // swipe horizontal?
                      if(Math.abs(deltaX) &gt; MIN_DISTANCE){
                          // left or right
                          if(deltaX &lt; 0) { this.onLeftToRightSwipe(); return true; }
                          if(deltaX &gt; 0) { this.onRightToLeftSwipe(); return true; }
                      }
                      else {
                              Log.i(logTag, "Swipe was only " + Math.abs(deltaX) + " long, need at least " + MIN_DISTANCE);
                              return false; // We don't consume the event
                      }
  
  
                      return true;
                  }
              }
              return false;
          }
      }
  }
  </code></pre>
  
  <p>Thanks in Advance.</p>