簡體   English   中英

如何使用畢加索從Dropbox加載圖像

[英]How to load images from Dropbox using Picasso

我正在嘗試從Dropbox加載圖像而沒有成功,但是我搜索到需要首先下載圖像,但是該圖像似乎是縮略圖。 我嘗試使用DropBox API,但它需要API密鑰,我只想下載圖像。 有什么有效的方法嗎?

我嘗試的最后一件事是:

public static Bitmap getBitmapFromURL(String src) {
try {
    URL url = new URL(src);
    HttpURLConnection connection = (HttpURLConnection) url.openConnection();
    connection.setDoInput(true);
    connection.connect();
    InputStream input = connection.getInputStream();
    Bitmap myBitmap = BitmapFactory.decodeStream(input);
    return myBitmap;
} catch (IOException e) {
    e.printStackTrace();
    return null;
}

它適用於普通圖像,但不適用於縮略圖!

您需要圖像的Dropbox URL(共享)。

請按照以下步驟操作-

  1. 在build.gradle(模塊)文件中添加以下依賴項。

    實現'com.squareup.picasso:picasso :(插入最新版本)'

  2. 同步您的項目

  3. 將保管箱網址存儲在變量中-

    String dropBoxURL =“(您的Dropbox URL)”;

  4. 像這樣在畢加索中使用該網址-

    Picasso.get()。load(“” + dropBoxURL).into(您的顯示類);

就這些。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM