2016-06-14 135 views
0

我已經使用Picasa API加載圖像,但問題是我不能夠設定爲圖像滾動能夠完整的圖像,這裏是我使用這樣設置壁紙適合屏幕

public class Utils { 
    private String TAG = Utils.class.getSimpleName(); 
    private Context _context; 
    private PrefManager pref; 

    // constructor 
    public Utils(Context context) { 
     this._context = context; 
     pref = new PrefManager(_context); 
    } 

    /* 
    * getting screen width 
    */ 
    @SuppressWarnings("deprecation") 
    public int getScreenWidth() { 
     int columnWidth; 
     WindowManager wm = (WindowManager) _context 
       .getSystemService(Context.WINDOW_SERVICE); 
     Display display = wm.getDefaultDisplay(); 

     final Point point = new Point(); 
     try { 
      display.getSize(point); 
     } catch (java.lang.NoSuchMethodError ignore) { 
      // Older device 
      point.x = display.getWidth(); 
      point.y = display.getHeight(); 
     } 
     columnWidth = point.x; 
     return columnWidth; 
    } 

    public void saveImageToSDCard(Bitmap bitmap) { 
     File myDir = new File(
       Environment 
       .getExternalStoragePublicDirectory(Environment.DIRECTORY_PICTURES), 
       pref.getGalleryName()); 

     myDir.mkdirs(); 
     Random generator = new Random(); 
     int n = 10000; 
     n = generator.nextInt(n); 
     String fname = "Wallpaper-" + n + ".jpg"; 
     File file = new File(myDir, fname); 
     if (file.exists()) 
      file.delete(); 
     try { 
      FileOutputStream out = new FileOutputStream(file); 
      bitmap.compress(Bitmap.CompressFormat.JPEG, 90, out); 
      out.flush(); 
      out.close(); 
      Toast.makeText(
        _context, 
        _context.getString(R.string.toast_saved).replace("#", 
          "\"" + pref.getGalleryName() + "\""), 
        Toast.LENGTH_SHORT).show(); 
      Log.d(TAG, "Wallpaper saved to: " + file.getAbsolutePath()); 

     } catch (Exception e) { 
      e.printStackTrace(); 
      Toast.makeText(_context, 
        _context.getString(R.string.toast_saved_failed), 
        Toast.LENGTH_SHORT).show(); 
     } 
    } 

    public void setAsWallpaper(Bitmap bitmap) { 
     WallpaperManager wallpaperManager = WallpaperManager.getInstance(_context); 
    try { 

     int widht=Resources.getSystem().getDisplayMetrics().widthPixels; 
     int height=Resources.getSystem().getDisplayMetrics().heightPixels; 
     wallpaperManager.suggestDesiredDimensions(widht, height); 
     wallpaperManager.setBitmap(bitmap); 
     } catch (IOException e) { 
     e.printStackTrace(); 
     }} 
} 

哪裏代碼我我錯了............................................... .........

回答

0

是由任何啓動器應用程序控制。如果你想要一個不滾動的壁紙,安裝一個不滾動壁紙的啓動器應用程序。 Jelly Bean之前的Android操作系統不允許您以編程方式設置動態壁紙。目前,果凍豆支持以編程方式更改動態壁紙而無需用戶干預