Eh bien je n'ai pas été capable de résoudre ce problème, et j'ai vraiment besoin d'obtenir le statut de téléchargement, lorsque vous téléchargez en utilisant MultipartUploadRequest, je veux imprimer avec un toast ou autre chose l'état qui apparaît sur la barre de notification. J'ai suivi ce tutoriel, mais je n'ai pas réussi: https://github.com/gotev/android-upload-service/wiki/Monitoring-upload-statusComment faire l'état de téléchargement de surveillance?
J'apprécie vraiment quelqu'un pour dire pourquoi je ne suis pas capable d'y parvenir s'il vous plaît. voici mon code:
public class CargarDatos extends AsyncTask<String, Void, String> {
protected String doInBackground(String... urls) {
////////////////-------------
String correo = campo_correo.getText().toString().trim();
String nombre = campo_nombre.getText().toString().trim();
String apellido= campo_apellido.getText().toString().trim();
String telefono= campo_telefono.getText().toString().trim();
String categoria= customspinner.getSelectedItem().toString().trim();
String titulo = campo_titulo.getText().toString().trim();
String descripcion = campo_descripcion.getText().toString().trim();
String latitud = Double.toString(latitudeeeee);
String longitud = Double.toString(longitudeeee);
String s = (campo_publico.isChecked() ? "1" : "0");
String r = (campo_terminos.isChecked() ? "1" : "0");
//getting the actual path of the image
String path = getPath(filePath);
//Uploading code
try {
String uploadId = UUID.randomUUID().toString();
//Creating a multi part request
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)
.startUpload(); //Starting the upload
} catch (Exception exc) {
Toast.makeText(TerminosYC.this.getActivity(), exc.getMessage(), Toast.LENGTH_SHORT).show();
}
// params comes from the execute() call: params[0] is the url.
try {
return downloadUrl(urls[0]);
} catch (IOException e) {
return "Unable to retrieve web page. URL may be invalid.";
}
}