試圖從kinvey公開訪問的文件下載到Android應用 嘗試以下代碼下載文件,如何從kinvey在android系統
FileOutputStream fos = new FileOutputStream(videoName);
FileMetaData meta = new FileMetaData(videoName);
meta.setId(videoName);
kinveyClient.file().downloadWithTTL(meta.getId(), 1200000, fos, new DownloaderProgressListener() {
@Override
public void progressChanged(MediaHttpDownloader downloader) throws IOException {
Log.i("", "progress updated: " + downloader.getDownloadState());
final String state = new String(downloader.getDownloadState().toString());
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
//tProgress.setText((tProgress.getText() == null) ? state : tProgress.getText() + "\n" + state)
}
});
}
@Override
public void onSuccess(Void result) {
}
@Override
public void onFailure(Throwable error) {
}
});
獲取事件的成功,但是數據沒有被接收。任何想法這將如何工作?
這樣得到錯誤:
failure com.kinvey.java.core.KinveyJsonResponseException: InsufficientCredentials
The credentials used to authenticate this request are not authorized to run this operation. Please retry your request with appropriate credentials
顯然,'progressChanged'方法被調用的MainThread已經,爲什麼你使用' runOnUiThread'? – Bhargav