我想两次调用回调函数。一旦它被执行,另一个函数就会被执行。我在第二个函数中保持吐司状态,该函数工作正常,但不再调用回调函数。
private void triggerWid(String message, CallbackContext callbackContext) {
Context context = this.cordova.getActivity().getApplicationContext();
WidgetBuilder widgetBuilder = new WidgetBuilder()
.setApiKey(LIQUIDPAY_API_KEY)
.setApiSecret(LIQUIDPAY_SECRET_KEY)
.setApplicationContext(context)
.build();
try {
widgetBuilder.run(new WidgetInterface() {
@Override
public void onExit() {
// result_status.setTextColor(Color.BLACK);
// result_status.setText(R.string.done);
CALLBACK_MESSAGE = "Done";
callbackContext.success("Done"); // Want to call here but not working
new Utils().showToast(context, "Widget Triggered");
}
});
} catch (IllegalStateException e) {
Log.e("WIDGET ACCESS", e.getMessage());
CALLBACK_MESSAGE = e.getMessage();
callbackContext.error("Error");
}
callbackContext.success(CALLBACK_MESSAGE); // Getting called first
}
您可以在代码中看到,第一次运行正常。但我也想下次再打。我可以知道怎么做吗?
谢谢。