public class CordovaPlugin
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
CordovaInterface |
cordova |
protected CordovaPreferences |
preferences |
CordovaWebView |
webView |
Constructor and Description |
---|
CordovaPlugin() |
Modifier and Type | Method and Description |
---|---|
boolean |
execute(java.lang.String action,
CordovaArgs args,
CallbackContext callbackContext)
Executes the request.
|
boolean |
execute(java.lang.String action,
org.json.JSONArray args,
CallbackContext callbackContext)
Executes the request.
|
boolean |
execute(java.lang.String action,
java.lang.String rawArgs,
CallbackContext callbackContext)
Executes the request.
|
protected android.net.Uri |
fromPluginUri(android.net.Uri pluginUri)
Refer to remapUri()
Added in cordova-android@4.0.0
|
java.lang.String |
getServiceName()
Returns the plugin's service name (what you'd use when calling pluginManger.getPlugin())
|
CordovaResourceApi.OpenForReadResult |
handleOpenForRead(android.net.Uri uri)
Called to handle CordovaResourceApi.openForRead() calls for a cdvplugin://pluginId/ URL.
|
boolean |
hasPermisssion() |
void |
initialize(CordovaInterface cordova,
CordovaWebView webView)
Called after plugin construction and fields have been initialized.
|
void |
onActivityResult(int requestCode,
int resultCode,
android.content.Intent intent)
Called when an activity you launched exits, giving you the requestCode you started it with,
the resultCode it returned, and any additional data from it.
|
void |
onConfigurationChanged(android.content.res.Configuration newConfig)
Called by the system when the device configuration changes while your activity is running.
|
void |
onDestroy()
The final call you receive before your activity is destroyed.
|
java.lang.Object |
onMessage(java.lang.String id,
java.lang.Object data)
Called when a message is sent to plugin.
|
void |
onNewIntent(android.content.Intent intent)
Called when the activity receives a new intent.
|
boolean |
onOverrideUrlLoading(java.lang.String url)
Allows plugins to handle a link being clicked.
|
void |
onPause(boolean multitasking)
Called when the system is about to start resuming a previous activity.
|
boolean |
onReceivedClientCertRequest(CordovaWebView view,
ICordovaClientCertRequest request)
Called when he system received an SSL client certificate request.
|
boolean |
onReceivedHttpAuthRequest(CordovaWebView view,
ICordovaHttpAuthHandler handler,
java.lang.String host,
java.lang.String realm)
Called when the system received an HTTP authentication request.
|
void |
onRequestPermissionResult(int requestCode,
java.lang.String[] permissions,
int[] grantResults)
Called by the system when the user grants permissions
|
void |
onReset()
Called when the WebView does a top-level navigation or refreshes.
|
void |
onRestoreStateForActivityResult(android.os.Bundle state,
CallbackContext callbackContext)
Called when a plugin is the recipient of an Activity result after the CordovaActivity has
been destroyed.
|
void |
onResume(boolean multitasking)
Called when the activity will start interacting with the user.
|
android.os.Bundle |
onSaveInstanceState()
Called when the Activity is being destroyed (e.g. if a plugin calls out to an external
Activity and the OS kills the CordovaActivity in the background).
|
void |
onStart()
Called when the activity is becoming visible to the user.
|
void |
onStop()
Called when the activity is no longer visible to the user.
|
protected void |
pluginInitialize()
Called after plugin construction and fields have been initialized.
|
void |
privateInitialize(java.lang.String serviceName,
CordovaInterface cordova,
CordovaWebView webView,
CordovaPreferences preferences)
Call this after constructing to initialize the plugin.
|
android.net.Uri |
remapUri(android.net.Uri uri)
Hook for redirecting requests.
|
void |
requestPermissions(int requestCode)
Called by the Plugin Manager when we need to actually request permissions
|
java.lang.Boolean |
shouldAllowBridgeAccess(java.lang.String url)
Hook for allowing page to call exec().
|
java.lang.Boolean |
shouldAllowNavigation(java.lang.String url)
Hook for blocking navigation by the Cordova WebView.
|
java.lang.Boolean |
shouldAllowRequest(java.lang.String url)
Hook for blocking the loading of external resources.
|
java.lang.Boolean |
shouldOpenExternalUrl(java.lang.String url)
Hook for blocking the launching of Intents by the Cordova application.
|
protected android.net.Uri |
toPluginUri(android.net.Uri origUri)
Refer to remapUri()
Added in cordova-android@4.0.0
|
public CordovaWebView webView
public CordovaInterface cordova
protected CordovaPreferences preferences
public final void privateInitialize(java.lang.String serviceName, CordovaInterface cordova, CordovaWebView webView, CordovaPreferences preferences)
public void initialize(CordovaInterface cordova, CordovaWebView webView)
protected void pluginInitialize()
public java.lang.String getServiceName()
public boolean execute(java.lang.String action, java.lang.String rawArgs, CallbackContext callbackContext) throws org.json.JSONException, java.lang.NoSuchMethodException
action
- The action to execute.rawArgs
- The exec() arguments in JSON form.callbackContext
- The callback context used when calling back into JavaScript.org.json.JSONException
java.lang.NoSuchMethodException
public boolean execute(java.lang.String action, org.json.JSONArray args, CallbackContext callbackContext) throws org.json.JSONException, java.lang.NoSuchMethodException
action
- The action to execute.args
- The exec() arguments.callbackContext
- The callback context used when calling back into JavaScript.org.json.JSONException
java.lang.NoSuchMethodException
public boolean execute(java.lang.String action, CordovaArgs args, CallbackContext callbackContext) throws org.json.JSONException
action
- The action to execute.args
- The exec() arguments, wrapped with some Cordova helpers.callbackContext
- The callback context used when calling back into JavaScript.org.json.JSONException
public void onPause(boolean multitasking)
multitasking
- Flag indicating if multitasking is turned on for apppublic void onResume(boolean multitasking)
multitasking
- Flag indicating if multitasking is turned on for apppublic void onStart()
public void onStop()
public void onNewIntent(android.content.Intent intent)
public void onDestroy()
public android.os.Bundle onSaveInstanceState()
public void onRestoreStateForActivityResult(android.os.Bundle state, CallbackContext callbackContext)
state
- Bundle containing the state of the plugincallbackContext
- Replacement Context to return the plugin result topublic java.lang.Object onMessage(java.lang.String id, java.lang.Object data)
id
- The message iddata
- The message datapublic void onActivityResult(int requestCode, int resultCode, android.content.Intent intent)
requestCode
- The request code originally supplied to startActivityForResult(),
allowing you to identify who this result came from.resultCode
- The integer result code returned by the child activity through its setResult().intent
- An Intent, which can return result data to the caller (various data can be
attached to Intent "extras").public java.lang.Boolean shouldAllowRequest(java.lang.String url)
public java.lang.Boolean shouldAllowNavigation(java.lang.String url)
public java.lang.Boolean shouldAllowBridgeAccess(java.lang.String url)
public java.lang.Boolean shouldOpenExternalUrl(java.lang.String url)
public boolean onOverrideUrlLoading(java.lang.String url)
url
- The URL that is trying to be loaded in the Cordova webview.public android.net.Uri remapUri(android.net.Uri uri)
public CordovaResourceApi.OpenForReadResult handleOpenForRead(android.net.Uri uri) throws java.io.IOException
java.io.IOException
protected android.net.Uri toPluginUri(android.net.Uri origUri)
protected android.net.Uri fromPluginUri(android.net.Uri pluginUri)
public void onReset()
public boolean onReceivedHttpAuthRequest(CordovaWebView view, ICordovaHttpAuthHandler handler, java.lang.String host, java.lang.String realm)
view
- The WebView that is initiating the callbackhandler
- The HttpAuthHandler used to set the WebView's responsehost
- The host requiring authenticationrealm
- The realm for which authentication is requiredpublic boolean onReceivedClientCertRequest(CordovaWebView view, ICordovaClientCertRequest request)
view
- The WebView that is initiating the callbackrequest
- The client certificate requestpublic void onConfigurationChanged(android.content.res.Configuration newConfig)
newConfig
- The new device configurationpublic void requestPermissions(int requestCode)
requestCode
- Passed to the activity to track the requestpublic boolean hasPermisssion()
public void onRequestPermissionResult(int requestCode, java.lang.String[] permissions, int[] grantResults) throws org.json.JSONException
requestCode
- permissions
- grantResults
- org.json.JSONException