我还没有能够解决这个问题,我真的需要获得上传状态,当你使用MultipartUploadRequest上传某些东西时,我想用吐司或其他任何东西打印出来的状态通知栏。 我一直在关注这些教程,但我没有成功:https://github.com/gotev/android-upload-service/wiki/Monitoring-upload-status
我真的很感激有人告诉我为什么我不能做到这一点。 这是我的代码:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="id1" class="someclass">
<p>some text
<label> Test content </label>
</p>
<div id="id2" style="overfolw:scroll">
<span>some text</span>
<div id="level3">
<label> Test content </label>
<a href="https://twitter.com/realDonaldTrump/status/882186896285282304" target=_blank rel=noopener>creepiness</a>
</div>
</div>
</div>
答案 0 :(得分:1)
如您提供的链接中所述,请使用setDelegate方法获取上传状态。该请求将如下所示
new MultipartUploadRequest(TerminosYC.this.getActivity(), uploadId, Constants.UPLOAD_URL)
.addFileToUpload(path, "image") //Adding file
.addParameter("name", correo) //Adding text parameter to the request
.addParameter("nombre", nombre)
.addParameter("apellido", apellido)
.addParameter("telefono", telefono)
.addParameter("categoria", categoria)
.addParameter("titulo", titulo)
.addParameter("descripcion", descripcion)
.addParameter("publico", s)
.addParameter("terminos", r)
.addParameter("latitud", latitud)
.addParameter("longitud", longitud)
.setNotificationConfig(new UploadNotificationConfig())
.setMaxRetries(2)
.setDelegate(new UploadStatusDelegate() { //Add these lines to get upload status
@Override
public void onProgress(Context context, UploadInfo uploadInfo) {
// your code here
}
@Override
public void onError(Context context, UploadInfo uploadInfo, ServerResponse serverResponse,
Exception exception) {
// your code here
}
@Override
public void onCompleted(Context context, UploadInfo uploadInfo, ServerResponse serverResponse) {
Toast.makeText(context, "Your success message here" + exception, Toast.LENGTH_SHORT).show();
}
@Override
public void onCancelled(Context context, UploadInfo uploadInfo) {
// your code here
}
}).startUpload();
文件上传后,将调用上述任何一种方法。在那打印您的消息
答案 1 :(得分:0)
调试的最佳方式使用Stetho facebook