我试图从我的一个操作中获取数据,当我使用断点或日志调试它时,值就在那里,但是当我运行它时它们总是空的,我该如何解决这个问题?
firebaseFirestore.collection("some collection").get()
.addOnSuccessListener(new OnSuccessListener<QuerySnapshot>() {
@Override
public void onSuccess(QuerySnapshot documentSnapshots) {
//I want to return these values I receive here...
});
//...and use the returned value here.
GraphRequest request = GraphRequest.newGraphPathRequest(
accessToken,
"some path",
new GraphRequest.Callback() {
@Override
public void onCompleted(GraphResponse response) {
//I want to return these values I receive here...
}
});
request.executeAsync();
//...and use the returned value here.
Kotlin协程
var result: SomeResultType? = null
someScope.launch {
result = someSuspendFunctionToRetrieveSomething()
//I want to return the value I received here...
}
Log.d("result", result.toString()) //...but it is still null here.
ETC。
蛊毒传说
红糖糍粑
有只小跳蛙
墨色风雨
相关分类