C5050-408 Free Dumps Study Materials
Question 3: An application developer needs to invoke Android native code from Javascript using Apache
Cordova API.
Which method signature should the application developer use?
A. cordova.exec(Plug-inName, ActionName, FailureCallback, SuccessCallback, Parameters);
B. cordova.exec(Plug-inName, ActionName, SuccessCallback, FailureCallback, Parameters);
C. cordova.exec(FailureCallback, SuccessCallback, Plug-inName, ActionName, Parameters);
D. cordova.exec(SuccessCallback, FailureCallback, Plug-inName, ActionName, Parameters);
Correct Answer: D
Explanation:
Here is an example:
cordova.exec(function(winParam) {}, function(error) {}, "service",
"action", ["firstArgument", "secondArgument", 42, false]);
The parameters explained in more detail:
- function(winParam) {} - Success function callback. Assuming your exec call completes successfully
, thisfunction will be invoked (optionally with any parameters you pass back to it)
- function(error) {} - Error function callback. If the operation does not complete successfully, thi
s function willbe invoked (optionally with an error parameter) - "service" - The service name to cal
l into on the native side. This will be mapped to a native class. More onthis in the native guides below
- "action" - The action name to call into. This is picked up by the native class receiving the exec call
, and,depending on the platform, essentially maps to a class's method. - [/* arguments */]
- Arguments to get passed into the native environment
References: http://docs.phonegap.com/en/2.3.0/guide_plugin-development_index.md.html