I have a webview in a fragment and have my own Bridgecallback services.
I have a javascript file TriggerEventsService.js
define(function(require){
var Service = require('BridgeService');
var TriggerEventsService = new Service({
name: "TriggerEventsService",
timeout : 3000
});
//Public API
TriggerEventsService.postHibernate = function(){
this.execute("postHibernate", {"event" : "App becoming inactive"}, function(){}, function(){});
};
In my HTML file index.html
function postEventHibernate(){
require(['TriggerEventsService'], function(ui){
ui.postHibernate();
});
}
Can I call this function directly from native android methods ?
In iOS I have done this:
NSString *jsString = [NSString stringWithFormat:@"require(['TriggerEventsService'],
function(ui){ui.postHibernate();});"];
[self.webView evaluateJavaScript:jsString completionHandler:nil];
and It works fine !I know a way to do it in iOS , figuring anyone can help me out if android has any direct method ?
I have seen other Answers but was not sure how to call the my TriggerEventsService.js - webview.loadUrl("WHAT EXACTLY SHOULD I CALL HERE ?");