java - 如何在主函数中获取“OnSuccessListener()”的输出
问题描述
interpreter.run(inputs, inputOutputOptions)
.addOnSuccessListener(
new OnSuccessListener<FirebaseModelOutputs>() {
@Override
public void onSuccess(FirebaseModelOutputs result) {
String str;
float[][] output = result.getOutput(0);
float[] probabilities = output[0];
float res=probabilities[0];
//Log.d(TAG, "onSuccess res: "+result.getOutput(0).toString());
System.out.println(output[0][0]);
System.out.println(output[0][1]);
if (output[0][0]>output[0][1]){
//till here my code is properly Running
str="Class1";
graphicOverlay.add(new FaceGraphic(graphicOverlay, face,str));
//But when i try to call this method this method not getting called same for else case
}
else {
//till here my code is properly Running
str="Class2";
}
}
})
.addOnFailureListener(
new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
}
});
如何在我的主要方法中获取变量“str”的值?
我尝试将字符串声明为静态类,但它给出了最后存储的输出(str 的值不会随着它的变化而更新)
谢谢你提前
解决方案
推荐阅读
- python - 我正在尝试获得不同的输出(带撇号)
- plsql - PL/SQL 传递关系(双向)
- reactjs - 如何仅在 React 中收到响应后从一个组件发出 GET 请求并加载不同的组件?
- c# - 为什么 .NET Core 的模型验证器会在验证消息中显示模型属性的名称而不是 JSON 字段名称?
- wordpress - WordPress:如何使用 WordPress 代码标准在保存时自动格式化文件?
- php - 当我运行这个时我得到一个数组
- jquery - 一起显示与同一交易相关的产品(Telerik Kendo UI Grid Jquery)
- python-3.x - 根据其他 DataFrame / python / pandas / numpy 中的值设置 DataFrame 中的列中的值
- javascript - 使用 Chart.js 来自 MySQL 查询的动态数据集
- laravel - 如何否定验证规则?拉拉维尔