[英]How to let Android return an inner class object to flutter
我使用 Flutter 调用 Android 第三方 SDK,但我不知道如何从 Flutter 的onCallback()
方法中获取值 'i' 和 'info'。
代码
public static void registerWith(PluginRegistry.Registrar registrar) {
channel = new MethodChannel(registrar.messenger(), CHANNEL);
LivenessPlug instance = new LivenessPlug(registrar.activity());
channel.setMethodCallHandler(instance);
}
@Override
public void onMethodCall(MethodCall methodCall, MethodChannel.Result result) {
if (methodCall.method.equals("getLivenessResult")) {
try {
getLivenessResult();
result.success();
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(activity, e.toString(), 2000).show();
}
}
else {
result.notImplemented();
}
}
public void getLivenessResult() {
OctopusLivenessManager.getInstance().
detectLiveness(activity, new OctopusLivenessCallback() {
@Override
public void onCallback(int i, OctopusLivenessInfo info) {
if (i == 0) {
Log.e("result", info.verificationPackage);
}
Toast.makeText(activity, i + "", Toast.LENGTH_SHORT).show();
}
});
}
}
@SuppressLint("WrongConstant")
@Override
public void onMethodCall(MethodCall methodCall, MethodChannel.Result result) {
if (methodCall.method.equals("getLivenessResult")) {
try {
getLivenessResult();
result.success();
} catch (Exception e) {
e.printStackTrace();
Toast.makeText(activity, e.toString(), 2000).show();
}
}
else {
result.notImplemented();
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.