Dropbox shareLink の取得に問題があります。ここでいくつかの回答に基づいてコードを変更しようとしましたが、出力は同じです。このコードのどの部分が間違っているのかわかりません
これが私のコードです:
public class loadMetadata extends AsyncTask<String, Void, String> {
private DropboxAPI<?> mApi;
private String mPath;
//private UploadRequest mRequest;
private Context mContext;
private String[] fnames;
String shareAddress = null;
//private int i = 0;
public loadMetadata(Context context, DropboxAPI<?> api, String dropboxPath) {
// We set the context this way so we don't accidentally leak activities
mContext = context.getApplicationContext();
//mFileLen = file.length();
mApi = api;
mPath = dropboxPath;
//mFile = file;
}
protected String doInBackground(String... String) {
String shareAddress = null;
int i = 0;
try {
Entry dropboxDir = mApi.metadata(mPath, 1000, null, true, null);
for (Entry ent : dropboxDir.contents)
{
if (!ent.isDir) {
DropboxLink shareLink = mApi.share(ent.path);
//shareAddress = shareLink.url.replaceFirst("https://www", "https://dl");
shareAddress = shareLink.url;
Log.d("Dropbox","dropbox share link " + shareAddress);
//fnames[i] = shareAddress;
}
i++;
}
} catch (DropboxException e) {
}
return shareAddress;
}
protected void onPostExecute(String result)
{
if(result != null)
{
Toast.makeText(mContext, result, Toast.LENGTH_LONG).show();
}
}
}