Я вызываю функцию, которая есть у меня в функциях firebase, и когда я пытаюсь получить возвращаемые данные, функция никогда не выполняется.
Я искал решение, но не нашел,
tornaposicio(12.9, 13.8).addOnCompleteListener(new OnCompleteListener<String[]>() {
@Override
public void onComplete(@NonNull Task<String[]> task) {
if (!task.isSuccessful()) {
Exception e = task.getException();
if (e instanceof FirebaseFunctionsException) {
FirebaseFunctionsException ffe = (FirebaseFunctionsException) e;
FirebaseFunctionsException.Code code = ffe.getCode();
Object details = ffe.getDetails();
}
i("Task didn't succeed", ".");
} else {
i("PARECE QUE FUNCIONA:",".");
String[] info = task.getResult();
i("Task succesfull", info[0]);
}
}
});
private Task<String[]> tornaposicio(double latitud, double longitud) {
// Create the arguments to the callable function.
HashMap<String, Double> posicio = new HashMap<String, Double>();
posicio.put("latitud", latitud);
posicio.put("longitud", longitud);
return mFunctions
.getHttpsCallable("tornaposicio")
.call(posicio)
.continueWith(new Continuation<HttpsCallableResult, String[]>() {
@Override
public String[] then(@NonNull Task<HttpsCallableResult>task) throws Exception {
// This continuation runs on either success or failure, but if the task
// has failed then getResult() will throw an Exception which will be
// propagated down.
result = (String[]) task.getResult().getData();
return result;
}
});
Код всегда вводится в "! Task.isSuccessful", и я хочу обратного.