Search in sources :

Example 1 with CordovaPlugin

use of org.apache.cordova.CordovaPlugin in project phonegap-facebook-plugin by Wizcorp.

the class CordovaActivity method onActivityResult.

@Override
protected /**
     * 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.
     *
     * @param requestCode       The request code originally supplied to startActivityForResult(),
     *                          allowing you to identify who this result came from.
     * @param resultCode        The integer result code returned by the child activity through its setResult().
     * @param data              An Intent, which can return result data to the caller (various data can be attached to Intent "extras").
     */
void onActivityResult(int requestCode, int resultCode, Intent intent) {
    LOG.d(TAG, "Incoming Result");
    super.onActivityResult(requestCode, resultCode, intent);
    Log.d(TAG, "Request code = " + requestCode);
    if (appView != null && requestCode == CordovaChromeClient.FILECHOOSER_RESULTCODE) {
        ValueCallback<Uri> mUploadMessage = this.appView.getWebChromeClient().getValueCallback();
        Log.d(TAG, "did we get here?");
        if (null == mUploadMessage)
            return;
        Uri result = intent == null || resultCode != Activity.RESULT_OK ? null : intent.getData();
        Log.d(TAG, "result = " + result);
        //            Uri filepath = Uri.parse("file://" + FileUtils.getRealPathFromURI(result, this));
        //            Log.d(TAG, "result = " + filepath);
        mUploadMessage.onReceiveValue(result);
        mUploadMessage = null;
    }
    CordovaPlugin callback = this.activityResultCallback;
    if (callback == null && initCallbackClass != null) {
        // The application was restarted, but had defined an initial callback
        // before being shut down.
        this.activityResultCallback = appView.pluginManager.getPlugin(initCallbackClass);
        callback = this.activityResultCallback;
    }
    if (callback != null) {
        LOG.d(TAG, "We have a callback to send this result to");
        callback.onActivityResult(requestCode, resultCode, intent);
    }
}
Also used : CordovaPlugin(org.apache.cordova.CordovaPlugin) Uri(android.net.Uri)

Example 2 with CordovaPlugin

use of org.apache.cordova.CordovaPlugin in project cordova-android by apache.

the class SystemWebChromeClient method onGeolocationPermissionsShowPrompt.

@Override
public /**
     * Instructs the client to show a prompt to ask the user to set the Geolocation permission state for the specified origin.
     *
     * This also checks for the Geolocation Plugin and requests permission from the application  to use Geolocation.
     *
     * @param origin
     * @param callback
     */
void onGeolocationPermissionsShowPrompt(String origin, Callback callback) {
    super.onGeolocationPermissionsShowPrompt(origin, callback);
    callback.invoke(origin, true, false);
    //Get the plugin, it should be loaded
    CordovaPlugin geolocation = parentEngine.pluginManager.getPlugin("Geolocation");
    if (geolocation != null && !geolocation.hasPermisssion()) {
        geolocation.requestPermissions(0);
    }
}
Also used : CordovaPlugin(org.apache.cordova.CordovaPlugin)

Example 3 with CordovaPlugin

use of org.apache.cordova.CordovaPlugin in project cordova-android by apache.

the class SystemWebChromeClient method openFileChooser.

public void openFileChooser(final ValueCallback<Uri> uploadMsg, String acceptType, String capture) {
    Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
    intent.addCategory(Intent.CATEGORY_OPENABLE);
    intent.setType("*/*");
    parentEngine.cordova.startActivityForResult(new CordovaPlugin() {

        @Override
        public void onActivityResult(int requestCode, int resultCode, Intent intent) {
            Uri result = intent == null || resultCode != Activity.RESULT_OK ? null : intent.getData();
            LOG.d(LOG_TAG, "Receive file chooser URL: " + result);
            uploadMsg.onReceiveValue(result);
        }
    }, intent, FILECHOOSER_RESULTCODE);
}
Also used : CordovaPlugin(org.apache.cordova.CordovaPlugin) Intent(android.content.Intent) Uri(android.net.Uri)

Example 4 with CordovaPlugin

use of org.apache.cordova.CordovaPlugin in project jpHolo by teusink.

the class ContactManager method pickContactAsync.

/**
     * Launches the Contact Picker to select a single contact.
     */
private void pickContactAsync() {
    final CordovaPlugin plugin = (CordovaPlugin) this;
    Runnable worker = new Runnable() {

        public void run() {
            Intent contactPickerIntent = new Intent(Intent.ACTION_PICK, Contacts.CONTENT_URI);
            plugin.cordova.startActivityForResult(plugin, contactPickerIntent, CONTACT_PICKER_RESULT);
        }
    };
    this.cordova.getThreadPool().execute(worker);
}
Also used : CordovaPlugin(org.apache.cordova.CordovaPlugin) Intent(android.content.Intent)

Example 5 with CordovaPlugin

use of org.apache.cordova.CordovaPlugin in project phonegap-facebook-plugin by Wizcorp.

the class PluginManager method getPlugin.

/**
     * Get the plugin object that implements the service.
     * If the plugin object does not already exist, then create it.
     * If the service doesn't exist, then return null.
     *
     * @param service       The name of the service.
     * @return              CordovaPlugin or null
     */
public CordovaPlugin getPlugin(String service) {
    PluginEntry entry = this.entries.get(service);
    if (entry == null) {
        return null;
    }
    CordovaPlugin plugin = entry.plugin;
    if (plugin == null) {
        plugin = entry.createPlugin(this.app, this.ctx);
    }
    return plugin;
}
Also used : CordovaPlugin(org.apache.cordova.CordovaPlugin) PluginEntry(org.apache.cordova.PluginEntry)

Aggregations

CordovaPlugin (org.apache.cordova.CordovaPlugin)6 Intent (android.content.Intent)2 Uri (android.net.Uri)2 CallbackContext (org.apache.cordova.CallbackContext)1 PluginEntry (org.apache.cordova.PluginEntry)1 PluginResult (org.apache.cordova.PluginResult)1 JSONException (org.json.JSONException)1