如何使用Picasso从Dropbox加载图像

问题描述 投票:0回答:1

我试图从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;
}

它适用于普通图像,但不适用于缩略图!

java android dropbox picasso
1个回答
0
投票

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

按照以下步骤 -

  1. 在build.gradle(模块)文件中添加以下依赖项。 实现'com.squareup.picasso:picasso :(插入最新版本)'
  2. 同步您的项目
  3. 将Dropbox URL存储在变量中 - String dropBoxURL =“(您的Dropbox URL)”;
  4. 在Picasso中使用这个URL就像这样 - Picasso.get()。load(“”+ dropBoxURL).into(你的显示类);

就这些。

© www.soinside.com 2019 - 2024. All rights reserved.