当前位置: 首页>>代码示例>>Java>>正文


Java CordovaPlugin类代码示例

本文整理汇总了Java中org.apache.cordova.CordovaPlugin的典型用法代码示例。如果您正苦于以下问题:Java CordovaPlugin类的具体用法?Java CordovaPlugin怎么用?Java CordovaPlugin使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


CordovaPlugin类属于org.apache.cordova包,在下文中一共展示了CordovaPlugin类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: requestPermissions

import org.apache.cordova.CordovaPlugin; //导入依赖的package包/类
/**
 * Requests "dangerous" permissions for the application at runtime. This is a helper method
 * alternative to cordovaInterface.requestPermissions() that does not require the project to be
 * built with cordova-android 5.0.0+
 *
 * @param plugin        The plugin the permissions are being requested for
 * @param requestCode   A requestCode to be passed to the plugin's onRequestPermissionResult()
 *                      along with the result of the permissions request
 * @param permissions   The permissions to be requested
 */
public static void requestPermissions(CordovaPlugin plugin, int requestCode, String[] permissions) {
    try {
        Method requestPermission = CordovaInterface.class.getDeclaredMethod(
                "requestPermissions", CordovaPlugin.class, int.class, String[].class);

        // If there is no exception, then this is cordova-android 5.0.0+
        requestPermission.invoke(plugin.cordova, plugin, requestCode, permissions);
    } catch (NoSuchMethodException noSuchMethodException) {
        // cordova-android version is less than 5.0.0, so permission is implicitly granted
        LOG.d(LOG_TAG, "No need to request permissions " + Arrays.toString(permissions));

        // Notify the plugin that all were granted by using more reflection
        deliverPermissionResult(plugin, requestCode, permissions);
    } catch (IllegalAccessException illegalAccessException) {
        // Should never be caught; this is a public method
        LOG.e(LOG_TAG, "IllegalAccessException when requesting permissions " + Arrays.toString(permissions), illegalAccessException);
    } catch(InvocationTargetException invocationTargetException) {
        // This method does not throw any exceptions, so this should never be caught
        LOG.e(LOG_TAG, "invocationTargetException when requesting permissions " + Arrays.toString(permissions), invocationTargetException);
    }
}
 
开发者ID:Andy-Ta,项目名称:COB,代码行数:32,代码来源:PermissionHelper.java

示例2: postMessage

import org.apache.cordova.CordovaPlugin; //导入依赖的package包/类
/**
 * Send a message to all plugins.
 *
 * @param id                The message id
 * @param data              The message data
 * @return                  Object to stop propagation or null
 */
public Object postMessage(String id, Object data) {
    Object obj = this.ctx.onMessage(id, data);
    if (obj != null) {
        return obj;
    }
    for (CordovaPlugin plugin : this.pluginMap.values()) {
        if (plugin != null) {
            obj = plugin.onMessage(id, data);
            if (obj != null) {
                return obj;
            }
        }
    }
    return null;
}
 
开发者ID:aabognah,项目名称:LoRaWAN-Smart-Parking,代码行数:23,代码来源:PluginManager.java

示例3: onOverrideUrlLoading

import org.apache.cordova.CordovaPlugin; //导入依赖的package包/类
/**
 * Called when the URL of the webview changes.
 *
 * @param url               The URL that is being changed to.
 * @return                  Return false to allow the URL to load, return true to prevent the URL from loading.
 */
public boolean onOverrideUrlLoading(String url) {
    // Deprecated way to intercept URLs. (process <url-filter> tags).
    // Instead, plugins should not include <url-filter> and instead ensure
    // that they are loaded before this function is called (either by setting
    // the onload <param> or by making an exec() call to them)
    for (PluginEntry entry : this.entryMap.values()) {
        List<String> urlFilters = urlMap.get(entry.service);
        if (urlFilters != null) {
            for (String s : urlFilters) {
                if (url.startsWith(s)) {
                    return getPlugin(entry.service).onOverrideUrlLoading(url);
                }
            }
        } else {
            CordovaPlugin plugin = pluginMap.get(entry.service);
            if (plugin != null && plugin.onOverrideUrlLoading(url)) {
                return true;
            }
        }
    }
    return false;
}
 
开发者ID:aabognah,项目名称:LoRaWAN-Smart-Parking,代码行数:29,代码来源:PluginManager.java

示例4: deliverPermissionResult

import org.apache.cordova.CordovaPlugin; //导入依赖的package包/类
private static void deliverPermissionResult(CordovaPlugin plugin, int requestCode, String[] permissions) {
    // Generate the request results
    int[] requestResults = new int[permissions.length];
    Arrays.fill(requestResults, PackageManager.PERMISSION_GRANTED);

    try {
        Method onRequestPermissionResult = CordovaPlugin.class.getDeclaredMethod(
                "onRequestPermissionResult", int.class, String[].class, int[].class);

        onRequestPermissionResult.invoke(plugin, requestCode, permissions, requestResults);
    } catch (NoSuchMethodException noSuchMethodException) {
        // Should never be caught since the plugin must be written for cordova-android 5.0.0+ if it
        // made it to this point
        LOG.e(LOG_TAG, "NoSuchMethodException when delivering permissions results", noSuchMethodException);
    } catch (IllegalAccessException illegalAccessException) {
        // Should never be caught; this is a public method
        LOG.e(LOG_TAG, "IllegalAccessException when delivering permissions results", illegalAccessException);
    } catch(InvocationTargetException invocationTargetException) {
        // This method may throw a JSONException. We are just duplicating cordova-android's
        // exception handling behavior here; all it does is log the exception in CordovaActivity,
        // print the stacktrace, and ignore it
        LOG.e(LOG_TAG, "InvocationTargetException when delivering permissions results", invocationTargetException);
    }
}
 
开发者ID:Andy-Ta,项目名称:COB,代码行数:25,代码来源:PermissionHelper.java

示例5: onGeolocationPermissionsShowPrompt

import org.apache.cordova.CordovaPlugin; //导入依赖的package包/类
@Override
/**
 * 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
 */
public 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);
    }

}
 
开发者ID:fachrihawari,项目名称:cordova-vuetify,代码行数:21,代码来源:SystemWebChromeClient.java

示例6: getPlugin

import org.apache.cordova.CordovaPlugin; //导入依赖的package包/类
/**
 * 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) {
    CordovaPlugin ret = pluginMap.get(service);
    if (ret == null) {
        PluginEntry pe = entryMap.get(service);
        if (pe == null) {
            return null;
        }
        if (pe.plugin != null) {
            ret = pe.plugin;
        } else {
            ret = instantiatePlugin(pe.pluginClass);
        }
        ret.privateInitialize(ctx, app, app.getPreferences());
        pluginMap.put(service, ret);
    }
    return ret;
}
 
开发者ID:aabognah,项目名称:LoRaWAN-Smart-Parking,代码行数:26,代码来源:PluginManager.java

示例7: onGeolocationPermissionsShowPrompt

import org.apache.cordova.CordovaPlugin; //导入依赖的package包/类
@Override
/**
 * 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
 */
public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissionsCallback 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);
    }

}
 
开发者ID:Im-Kevin,项目名称:cordova.plugins.X5WebView,代码行数:21,代码来源:X5WebChromeClient.java

示例8: takePicture

import org.apache.cordova.CordovaPlugin; //导入依赖的package包/类
public void takePicture(int returnType, int encodingType)
    {
        // Save the number of images currently on disk for later
        this.numPics = queryImgDB(whichContentStore()).getCount();

        // Let's use the intent and see what happens
        Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);

        // Specify file so that large image is captured and returned
        File photo = createCaptureFile(encodingType);
        this.imageUri = new CordovaUri(FileProvider.getUriForFile(cordova.getActivity(),
                applicationId + ".provider",
                photo));
        intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, imageUri.getCorrectUri());
        //We can write to this URI, this will hopefully allow us to write files to get to the next step
        intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);

        if (this.cordova != null) {
            // Let's check to make sure the camera is actually installed. (Legacy Nexus 7 code)
            PackageManager mPm = this.cordova.getActivity().getPackageManager();
            if(intent.resolveActivity(mPm) != null)
            {

                this.cordova.startActivityForResult((CordovaPlugin) this, intent, (CAMERA + 1) * 16 + returnType + 1);
            }
            else
            {
                LOG.d(LOG_TAG, "Error: You don't have a default camera.  Your device may not be CTS complaint.");
            }
        }
//        else
//            LOG.d(LOG_TAG, "ERROR: You must use the CordovaInterface for this to work correctly. Please implement it in your activity");
    }
 
开发者ID:Andy-Ta,项目名称:COB,代码行数:34,代码来源:CameraLauncher.java

示例9: execute

import org.apache.cordova.CordovaPlugin; //导入依赖的package包/类
public boolean execute(String action, final JSONArray args, final CallbackContext callbackContext) throws JSONException {
	 this.callbackContext = callbackContext;
	 this.params = args.getJSONObject(0);
	if (action.equals("getPictures")) {
		Intent intent = new Intent(cordova.getActivity(), MultiImageChooserActivity.class);
		int max = 20;
		int desiredWidth = 0;
		int desiredHeight = 0;
		int quality = 100;
		if (this.params.has("maxImages")) {
			max = this.params.getInt("maxImages");
		}
		if (this.params.has("width")) {
			desiredWidth = this.params.getInt("width");
		}
		if (this.params.has("height")) {
			desiredWidth = this.params.getInt("height");
		}
		if (this.params.has("quality")) {
			quality = this.params.getInt("quality");
		}
		intent.putExtra("MAX_IMAGES", max);
		intent.putExtra("WIDTH", desiredWidth);
		intent.putExtra("HEIGHT", desiredHeight);
		intent.putExtra("QUALITY", quality);
		if (this.cordova != null) {
			this.cordova.startActivityForResult((CordovaPlugin) this, intent, 0);
		}
	}
	return true;
}
 
开发者ID:disit,项目名称:siiMobilityAppKit,代码行数:32,代码来源:ImagePicker.java

示例10: onDestroy

import org.apache.cordova.CordovaPlugin; //导入依赖的package包/类
/**
 * The final call you receive before your activity is destroyed.
 */
public void onDestroy() {
    for (CordovaPlugin plugin : this.pluginMap.values()) {
        if (plugin != null) {
            plugin.onDestroy();
        }
    }
}
 
开发者ID:aabognah,项目名称:LoRaWAN-Smart-Parking,代码行数:11,代码来源:PluginManager.java

示例11: onGeolocationPermissionsShowPrompt

import org.apache.cordova.CordovaPlugin; //导入依赖的package包/类
/**
 * 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
 */
public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissionsCallback 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);
    }

}
 
开发者ID:jeremyup,项目名称:cordova-plugin-x5-webview,代码行数:20,代码来源:X5WebChromeClient.java

示例12: execute

import org.apache.cordova.CordovaPlugin; //导入依赖的package包/类
public boolean execute(String action, final JSONArray args, final CallbackContext callbackContext) throws JSONException {
	 this.callbackContext = callbackContext;
	 this.params = args.getJSONObject(0);
	if (action.equals("getPictures")) {
		Intent intent = new Intent(cordova.getActivity(), MultiImageChooserActivity.class);
		int max = 20;
		int desiredWidth = 0;
		int desiredHeight = 0;
		int quality = 100;
		if (this.params.has("maximumImagesCount")) {
			max = this.params.getInt("maximumImagesCount");
		}
		if (this.params.has("width")) {
			desiredWidth = this.params.getInt("width");
		}
		if (this.params.has("height")) {
			desiredHeight = this.params.getInt("height");
		}
		if (this.params.has("quality")) {
			quality = this.params.getInt("quality");
		}
		intent.putExtra("MAX_IMAGES", max);
		intent.putExtra("WIDTH", desiredWidth);
		intent.putExtra("HEIGHT", desiredHeight);
		intent.putExtra("QUALITY", quality);
		if (this.cordova != null) {
			this.cordova.startActivityForResult((CordovaPlugin) this, intent, 0);
		}
	}
	return true;
}
 
开发者ID:abelabbesnabi,项目名称:cordova-plugin-image-picker,代码行数:32,代码来源:ImagePicker.java

示例13: onReset

import org.apache.cordova.CordovaPlugin; //导入依赖的package包/类
/**
 * Called when the app navigates or refreshes.
 */
public void onReset() {
    for (CordovaPlugin plugin : this.pluginMap.values()) {
        if (plugin != null) {
            plugin.onReset();
        }
    }
}
 
开发者ID:aabognah,项目名称:LoRaWAN-Smart-Parking,代码行数:11,代码来源:PluginManager.java

示例14: signInWithGoogle

import org.apache.cordova.CordovaPlugin; //导入依赖的package包/类
private void signInWithGoogle(final CallbackContext callbackContext) {

        this.signinCallback = callbackContext;

        final CordovaPlugin plugin = this;

        cordova.getThreadPool().execute(new Runnable() {
            @Override
            public void run() {

                Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(googleApiClient);
                cordova.startActivityForResult(plugin, signInIntent, RC_SIGN_IN);
            }
        });
    }
 
开发者ID:kanodeveloper,项目名称:cordova-plugin-firebase-performance-ka,代码行数:16,代码来源:FirebaseAuthenticationPlugin.java

示例15: pickContactAsync

import org.apache.cordova.CordovaPlugin; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:rodrigonsh,项目名称:alerta-fraude,代码行数:14,代码来源:ContactManager.java


注:本文中的org.apache.cordova.CordovaPlugin类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。