Issue
I am implementing a ListenableWorker class according to this official documentation from google
I am getting the following error Cannot resolve symbol 'CallbackToFutureAdapter'
Below is the method i am trying to implement
return CallbackToFutureAdapter.getFuture(completer -> {
Callback callback = new Callback() {
int successes = 0;
@Override
public void onFailure(Call call, IOException e) {
completer.setException(e);
}
@Override
public void onResponse(Call call, Response response) {
++successes;
if (successes == 100) {
completer.set(Result.success());
}
}
};
completer.addCancellationListener(cancelDownloadsRunnable, executor);
for (int i = 0; i < 100; ++i) {
downloadAsynchronously("https://www.example.com", callback);
}
return callback;
});
what should i import to resolve CallbackToFutureAdapter i already have Android X implemented in my app level gradle
Solution
just add the following import:
implementation "androidx.concurrent:concurrent-futures:1.1.0"
As per documentation AndroidX Concurrent libraries
Answered By - Evgeni Vilenchik
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.