External Object for Android with callback Event - genexus

I'm building an External Object for Android.
I have an asynchronous method and I guess I must to use an Event into the External Object to receive it's callback in Genexus.
But, can anyone show me how to trigger this event in GX from the android java class?

This method:
mCoordinator.runAction("yourEvent", null);
And the mCoordinator you can get it at the constructor:
public YourUC(Context context, Coordinator coordinator, LayoutItemDefinition definition){
}

Related

onTurnError is not called from TeamsActivityHandler.onInvokeActivity

i'm implementing a bot for microsoft teams using com.microsoft.bot:bot-integration-core version 4.14
i'm subclassing TeamsActivityHandler and overriding methods like onMessageActivity and onAdaptiveCardInvoke
i also use BotFrameworkAdapter to add some middleware and onTurnError handler.
when i have an action, triggered from a button click for example, and this action raises an exception, then onTurnError is not called, since an error is handled in TeamsActivityHandler (https://github.com/microsoft/botbuilder-java/blob/main/libraries/bot-builder/src/main/java/com/microsoft/bot/builder/teams/TeamsActivityHandler.java#L181)
in case on an error in onMessageActivity, the onTurnError is called fine.
if i subclass from a parent of TeamsActivityHandler, which is ActivityHandler then i assume error handling will work fine.
so my question is:
how is onTurnError is supposed to be used in case of subclassing TeamsActivityHandler ?

How do you cancel navigation in MvvmCross 6.x?

I'm converting an MVVMCross 4.x app to MvvmCross 6.x.
Previously if I wanted to intercept the showing of a view model and cancel it then I would subclass the MvxViewPresenter and override the Task<bool> Show(MvxViewModelRequest request) method. I'm struggling to find the equivalant in MvvmCross 6.0
I've tried hooking in to the Mvx.IoCProvider.Resolve<IMvxNavigationService>().BeforeNavigate event but this gets called after the Prepare() and Initialize() view model methods.
How do I intercept the call before the ViewModel.Initialize() method is called and cancel the navigation?

session state service failed prism (Windows store app)

I am trying to react to suspend events within my Windows Store App. I added the appropriate callback method, but I've run into a problem:
App.Current.Suspending += Current_Suspending;
void Current_Suspending(object sender, Windows.ApplicationModel.SuspendingEventArgs e){}
The problem is that, when I trigger the suspension event in Visual Studio and the callback method is called (I have checked it with a breakpoint), it immediately terminates with an Exception:
session state service failed.
Any suggestions on how to solve this problem?
If you are using Prism as I was this can happen when the SessionStateService chokes on serializing an object. Relevant navigation parameters and anything manually added get serialized at app termination or suspension. In my specific case i had a non-nullable enum that wasn't being set on an object used as a navigation parameter. I used the following to verify the DataContractSerializer wasn't having issues with object.
test.Add("testitem", new WorkflowStep());
MemoryStream sessionData = new MemoryStream();
DataContractSerializer serializer = new DataContractSerializer(typeof(Dictionary<string, object>));
serializer.WriteObject(sessionData, test);

Why Cordova battery-status event listeners are added to the window object?

On the Cordova (aka PhoneGap) documentation, all examples show event listeners added to the document object, for example:
document.addEventListener("backbutton", onBackKeyDown, false);
...except for the three battery-status event listeners (batterystatus, batterycritical, batterylow), whose listeners are added to the window object. For example:
window.addEventListener("batterycritical", yourCallbackFunction, false);
Why is that?
Thank you! I was pulling my hair out why the event wasn't triggering. I did bind it to the document. Maybe they want to be compatible with Battery Status Api. http://www.w3.org/TR/battery-status/

Callback or completion event for Ti.Platform.openUrl or Ti.App.fireEvent

Does anyone know a way of finding out precisely when either a Ti.Platform.openUrl or Ti.App.fireEvent finishes? Something like a callback or an completion event? Thanks.
Nathan
App-level events are global to your app. They are accessible in all contexts, functional scopes, CommonJS modules, and so forth. You can fire them and listen for them via the Ti.App module as follows.
//Creating an app level custom event
Ti.App.addEventListener('myAppEvent', myCallBack);
//Fire the event like
Ti.App.fireEvent('myAppEvent');
//Callback function of your custom event
function myCallBack(e){
alert("In call back. App level event get fired!!!");
}
Please refer Event handling in Titanium for more details

Resources