List of usage examples for android.os Vibrator cancel
@RequiresPermission(android.Manifest.permission.VIBRATE) public abstract void cancel();
From source file:com.vibrationapps.Vibration.java
/** * Executes the request and returns PluginResult. * * @param action The action to execute. * @param args JSONArray of arguments for the plugin. * @param callbackContext The callback context used when calling back into JavaScript. * @return True when the action was valid, false otherwise. *///from ww w. j av a2s. c o m public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException { Vibrator vibra = (Vibrator) cordova.getActivity().getSystemService(Context.VIBRATOR_SERVICE); if (action.equals("vibrate")) { vibra.vibrate(args.getLong(0)); } else if (action.equals("vibrateArr")) { JSONArray jsonArray = (JSONArray) args.getJSONArray(0); long[] list = new long[jsonArray.length()]; if (jsonArray != null) { int len = jsonArray.length(); for (int i = 0; i < len; i++) { list[i] = jsonArray.getLong(i); } } vibra.vibrate(list, args.getInt(1)); } else if (action.equals("cancel")) { vibra.cancel(); } else if (action.equals("hasVibrator")) { } else { return false; } // Only alert and confirm are async. callbackContext.success(); return true; }